LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-03-2010, 11:32 AM   #1
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Rep: Reputation: 0
Question 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.
 
Old 12-03-2010, 11:35 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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.
 
Old 12-03-2010, 10:10 PM   #3
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 12-06-2010, 08:56 AM   #4
tardis1
LQ Newbie
 
Registered: Sep 2010
Location: Texas
Distribution: Ubuntu Server lucid, Ubuntu Desktop maverick
Posts: 15

Original Poster
Rep: Reputation: 0
Question 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,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Passing commands through an SSH shell in a bash script buee Linux - Newbie 12 07-01-2010 01:28 AM
[SOLVED] Bash Script Problem - Stops after While loop K_REY_C Linux - Newbie 7 05-13-2010 06:59 PM
Bash script, if else statement to ping & ssh connection to correct i.p. VipX1 Linux - Newbie 2 12-31-2009 11:05 PM
Bash Script to log off of ssh connection Betzie Programming 4 07-07-2009 04:29 PM
ssh - how to close connection from bash script babag Linux - Networking 7 05-30-2008 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration