I have install jenkins in ubuntu OS. when i build a project and run some executable shell script then it doen't access the file. how to add sudo password in shell script.
Asked
Active
Viewed 1,713 times
0
-
1"how to add sudo password in shell script." why?! bad idea. Please learn how to add users to a group and how to set executable permissions for a group. – Rinzwind May 30 '21 at 13:30
-
Does this answer your question? [How do I tell a shell script my password?](https://askubuntu.com/questions/612142/how-do-i-tell-a-shell-script-my-password) – Alexandre Teles Jun 03 '21 at 22:46
1 Answers
0
Kartik,As Rinzwind has already advised you that this is the bad idea and must be ignored or find other way around, by setting executable permissions to the user/group, but for the purpose of educational only, I am adding the possible solution, Pl check let me know if it can help you
create a bash script mysudo # you can name it anything
#!/usr/bin/bash
echo "your_password" | sudo -S sleep 1 && sudo su
wait for 1 second so the echoed password could be filled in
replace your_password with your actual password
Amul Bhatia
- 358
- 2
- 6
- 13