LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-01-2012, 05:15 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
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:
Code:
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:
Code:
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.
 
  


Reply



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 12:59 PM
Running server in shared screen session deus1 Linux - Server 1 04-04-2008 12:28 PM
Starting a command in an already-running screen session Wynd Linux - General 1 10-24-2007 03:10 PM
running X in a screen session jumanji Linux - General 2 04-22-2004 01:57 PM
Running a command in a screen session ifan Linux - Newbie 0 07-16-2003 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:51 PM.

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