2

I have a ssh calling a script in a server, named /opt/scripts/script1.sh.

sshpass -p 'password' ssh user@ip /opt/scripts/script1.sh

(I know sshpass is not secure but there's a reason for that in this context)

This script does a bunch of stuff then calls another script, doing bash /opt/scripts/script2.sh.

If I interactively ssh into this machine, and run /opt/scripts/script1.sh, /opt/scripts/script2.sh is called. But if I do

sshpass -p 'password' ssh user@ip /opt/scripts/script1.sh

/opt/scripts/script2.sh is not called. I don't have an error (even doing set -x), nothing. I don't know why it works in one way but not in another. Can someone explain why this happens?

  • You mention that script1.sh "does a bunch of stuff" before starting script2.sh; do you still see the problem if you remove all that, so that script1.sh only contains the line bash script2.sh? – JigglyNaga Aug 22 '18 at 9:44
  • 1
    Are you sure you're calling the same script? What does set -x say it's doing when it calls bash ...script2? – Jeff Schaller Aug 22 '18 at 10:39
  • 1
    Write a mcve. It helps you finding the problem. – ceving Aug 22 '18 at 11:04