I want to run the following sample bash script which needs sudo password for a command
#!/bin/bash
kinit #needs sudo password
vi hello.txt
while running the above script it is asking for password.
How can i pass the username and password in the command itself or is there any better way i can skip passing my password in the script ?
You can't—at least, not the way you think.
You have a couple of options:
sudo -v
. The credentials will be temporarily cached, giving you time to run your script.One or more of these will definitely get you where you want to go—just not the way you wanted to get there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With