LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-14-2008, 06:09 PM   #1
inthecrossfire
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
Screen Command with Bash Scripting


I'm trying to create a BASH script that uses screen to connect to a remote system and run a few commands. However there aren't any instances of screen running when the script is run. Is there a way to start an instance of screen in the background so that I can then send commands to it using 'screen -X'? The current problem is that if I invoke screen it just starts the terminal in the foreground and BASH loses control.

Thanks.
 
Old 07-14-2008, 08:56 PM   #2
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
To run any command in the background,
add an & to the end of the command.
 
Old 07-14-2008, 11:23 PM   #3
inthecrossfire
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
For whatever reason, screen decides not to go to the background when run as "screen &". Any ideas?
 
Old 07-15-2008, 08:31 AM   #4
jmfv
LQ Newbie
 
Registered: Nov 2006
Distribution: Debian Stable
Posts: 17

Rep: Reputation: 1
Hello.Try

Code:
screen -d -m
Cheers
 
Old 07-15-2008, 10:05 AM   #5
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
+1 jmfv

some more screen that might help

$: screen -d -m links google.com

$: screen -d -m links slackware.com

$: screen -r
There are several suitable screens on:
31426..{MY HOST NAME} (Detached)
31434..{MY HOST NAME} (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

$: screen -r {31426}

the {31426} is the first num from screen -r output in previous command. This will bring up the `links google.com` page.

So now you should have your links up to google.com on your screen. You can surf around and whatever, or if its a script you could be watching the output.

To detach this screen and go back to your normal console hit <CTRL>+<A> and then <CTRL>+<D>. Now the screen to links google.com will be back in the background.

There are lots of other <CTRL>+<D> and then <CTRL>+<KEY> commands check out the man file for more.

Last edited by skog; 07-15-2008 at 10:06 AM.
 
Old 07-15-2008, 01:18 PM   #6
inthecrossfire
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Awesome. Thanks very much.
 
  


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
shell scripting/ bash/ a command with 3 parameters mayaabboud Programming 4 01-05-2008 10:22 AM
Bash scripting: redirecting input to a command hal8000b Programming 2 12-10-2007 07:29 AM
Wrong parsing of ls command in bash scripting itz2000 Programming 3 04-25-2007 10:23 AM
Bash Scripting - echo command question gbhil Programming 2 04-27-2005 07:27 PM
Bash command scripting otisthegbs Linux - General 6 07-06-2004 12:06 AM


All times are GMT -5. The time now is 12:33 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration