Hi automating some task to change the user from local to sudo su root and connect to ftp server and get the .gz file from ftp to local machine gunzip that file and restore into PostgreSQL BD, but i'm not able to change the user
some sample script that i used in script
1.spawn sudo -s <
expect "password for username:"
send -- "production123\r"
expect eof
error:-
-bash: ./dbbackup.sh: /usr/bin: bad interpreter: Permission denied
- sudo -kSs << EOF
production123
whoami
echo "Not a good idea to have a password encoded in plain text"
EOF
error :its also not switching the user
3.sudo -s <
expect "password for username:"
send -- "production123\r"
expect eof
error
[production@nsuat crons]$ ./dbbackup.sh ./dbbackup.sh: line 1: EOF: No such file or directory ./dbbackup.sh: line 3: expect: command not found ./dbbackup.sh: line 5: send: command not found ./dbbackup.sh: line 7: expect: command not found [production@nsuat crons]$
sudo
from a script, but there's plenty of other stuff also which blurs the context...