I have a script that can only run when using the sudo command and password. I need to read the sudo user's password from etc/passwd file without getting prompted for a password.
Here is my code:
The code remove ppids and orphans from sasworks directory.
cleanwork= 'sudo -S apt-get update <~/passwd.txt /sas/sashome/sasfounadation/utilities/bin/cleanwork /sasworks'
cleanwork93= 'sudo -S apt-get update <~/passwd.txt /sas93/sashome/sasfounadation/utilities/bin/cleanwork /sasworks'
sasadm is a sudo user and is the only user who can run the code. I donot need to add sasadm to the script. The password for sasadm is in the etc/passwd,txt. The password need to be encrpyted.
passwd.txt content is: