LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 06-01-2011, 10:03 AM   #1
jgombos
Member
 
Registered: Jul 2003
Posts: 256

Rep: Reputation: 32
sending commands to GNU Screen to be *sourced*, not subshelled


If I have a GNU screen session running, commands can generally be sent to it as follows:
Code:
screen -X 'exec echo hi'
However, I need a command to execute within the shell. How is that done? E.g., to set a variable, one might be tempted to run:
Code:
screen -X 'exec export MYVAR=something'
This is obviously useless when the command executes in a subshell which exits.
 
Old 06-01-2011, 10:14 AM   #2
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
I suspect that you are going to need to send the remote system a command which instructs it to "source" the contents of a file which you have also sent.
 
1 members found this post helpful.
Old 06-01-2011, 11:36 AM   #3
jgombos
Member
 
Registered: Jul 2003
Posts: 256

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by sundialsvcs View Post
I suspect that you are going to need to send the remote system a command which instructs it to "source" the contents of a file which you have also sent.
That's a bit of a hack.. but could do the job. Thanks for the suggestion.
 
Old 06-02-2011, 11:45 AM   #4
jgombos
Member
 
Registered: Jul 2003
Posts: 256

Original Poster
Rep: Reputation: 32
It just occurred to me that sourcing a script is not going to work, because the exec command will still execute the source command in a subshell. Screen's "exec" command seems to execute everything inside of a child shell.

(EDIT)
Screen has a setenv command, I've just discovered. And it has a stuff command, which will inject a string onto the CLI, and if the string ends with a caret-M (^M), the command will be executed. Just what I need.

Last edited by jgombos; 06-03-2011 at 03:30 PM.
 
  


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
Sending commands to a screen session owned by root. Rendman Linux - Software 3 01-28-2011 02:34 AM
Sending commands to a screen session tirwit Linux - Software 6 08-08-2010 10:46 PM
installing screen(http://www.gnu.org/software/screen/) dreamlemon Solaris / OpenSolaris 5 09-29-2007 04:36 PM
Gnu Screen Commands PatrickNew Linux - Software 2 12-15-2006 06:23 PM
what is GNU and what are the commands? anjum Linux - Software 9 08-03-2005 03:32 PM


All times are GMT -5. The time now is 01:09 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration