Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 08-01-2012, 06:15 PM   #1
Senior Member
Registered: May 2009
Location: WV, USA
Distribution: Xubuntu, Slackware, Amazon Linux
Posts: 1,905
Blog Entries: 20

Rep: Reputation: 126Reputation: 126
Input to a screen session from a script running outside

I know I can start a background screen session and specify a program using a command like:
screen -dmS sessionname program args ...
But what I would also like for the script to do is wait a few seconds and then provide some terminal input to what is running in that session, just as if it had been typed in, but without actually displaying that session or being stuck in it.

The purpose is to start something running in the screen session automatically, along with the initial input. An example would be starting a regular interactive shell, then feeding the first command to that shell through screen, with the expectation of later connecting to that session, see the results, and type more.

Pretending that an option "--input" existed (that causes its command line arguments to be entered to the session), the script could do:
screen -dmS sessionname
sleep 9
screen --input -S sessionname ssh me@remotehost\n
sleep 3
screen --input -S sessionname mypassword\n
And then I could later connect to that session with a shell on the remote host that I can type commands on, and if/when I exit that shell, have a shell on the local host.

Being able to take a snapshot of that screen session display contents, written to a file or stdout, would be nice plus.


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
Launch script to be interpreted on screen session? Super TWiT Linux - Software 1 02-16-2010 01:59 PM
Running server in shared screen session deus1 Linux - Server 1 04-04-2008 01:28 PM
Starting a command in an already-running screen session Wynd Linux - General 1 10-24-2007 04:10 PM
running X in a screen session jumanji Linux - General 2 04-22-2004 02:57 PM
Running a command in a screen session ifan Linux - Newbie 0 07-16-2003 08:12 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:19 AM.

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