Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm new to shell scripting and I tried to have a script ssh into another machine and perform some commands. I have the public/private key set up so I'm not prompted for a password when I ssh into the other machine manually. The problem is that the scripts stops after sshing into the other machine unless the ssh is exited. In the code below, the second and third line are not ex

ssh usr@myserver.com 'installmyprogram.sh'
echo "Successfully logged in?"
pwd
share|improve this question

1 Answer 1

up vote 1 down vote accepted

That's the way shell scripts work. Given a file with

ssh usr@myserver.com 'installmyprogram.sh'
echo "Successfully logged in?"
pwd

First the shell executes the command on the first line, when that command is finished, it executes the command on the second line.

You may want to do something like this (untested)

ssh usr@myserver.com 'installmyprogram.sh; echo "Successfully logged in?"; pwd'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.