LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SSH connection from BASH script stops further BASH script commands (http://www.linuxquestions.org/questions/linux-newbie-8/ssh-connection-from-bash-script-stops-further-bash-script-commands-848187/)

tardis1 12-03-2010 11:32 AM

SSH connection from BASH script stops further BASH script commands
 
Here is what I am trying to do:

Code:

#!/bin/bash
ssh -D localhost:9900 me@myhost.com
firefox -P profilename

What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.

If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.

Any help is much appreciated. Thanks in advance.

MS3FGX 12-03-2010 11:35 AM

First, you might want to add the "-n" option to your SSH line, which creates a non-interactive session (in other words, you don't see a login prompt from the remote machine, it just forwards the ports).

But in general, adding "&" to the end of any command will push it into the background. In scripts, this will let other commands in the script execute even if the previous one has not completed.

tardis1 12-03-2010 10:10 PM

Thanks, I will try the -n. Haven't seen that in any lists of switches. I did try the '&' on the end and the connection would not work. It said something about a stdin problem.

tardis1 12-06-2010 08:56 AM

More ssh help needed
 
OK, I tried the -n option for my ssh command and I received the following error when the script ran:

Code:

Pseudo-terminal will not be allocated because stdin is not a terminal.
In addition, the ssh connection did not occur and I receive the same error when using the '&' appended to the command.

While the script does continue without waiting on the ssh connection, I also need the connection to make in order for the script to function properly.

Thanks,


All times are GMT -5. The time now is 08:03 PM.