-1

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.

1 Answers1

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
  • 378
  • 2
  • 6
  • 13