I'm testing if i can run the script as user1 then sudo as user2 to execute a section of the script as user, then revert back to user1 afterwards.
Apparently my script gets stuck after the first sudo and does not execute the succeeding lines. How can this be resolved?
Apologies as I'm really not experienced in shell scripting
#!/bin/bash
whoami
ls -lrt /myfolder
sudo -i -u user2
whoami
sftp ${othersvr} <<EOF
cd /tgtpath
lcd /myfolder
get -p *.txt
exit
EOF
sudo -i -u user1
whoami
ls -lrt /myfolder
exitfrom each invocation ofsudo(I'm pretty sure). Good luck.