screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ SOLVED] How to use screen configuration with command option


From: J. Bakshi
Subject: Re: [ SOLVED] How to use screen configuration with command option
Date: Tue, 05 Jan 2010 15:53:33 +0530
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Chris Jones wrote:
> On Mon, Dec 28, 2009 at 11:19:42AM EST, Aaron Davies wrote:
>   
>> On Monday, December 28, 2009,  <address@hidden> wrote:
>>     
>
> [..]
>
>   
>>>> Do you mean something like this:
>>>>
>>>> $ ssh address@hidden
>>>> $ screen -S $HOSTNAME
>>>> $ screen -S $HOSTNAME -X hardstatus alwayslastline "Hello World!"
>>>> $ screen -S ..           <other screen command> ...
>>>>
>>>> And this is not working in your case..??
>>>>
>>>> CJ
>>>>         
>>> Hello CJ,
>>>
>>> [-X] is applicable for existing session only.
>>>       
>> The short answer afaik is that you cannot pass arbitrary options to a
>> new screen session while starting it; you have to create a screen and
>> then use -X to send commands to it.
>>     
>
> His script creates a screen session, and if screen doesn't start, he
> bails out. When screen does come up, he has an "existing session" and
> so.. he can issue as many 'screen -X's as he wants, right?
>
> Still not sure why he wants to do it that way, though.
>
>   
>> If this is a common problem, it might be worth looking at adding
>> something like ssh's "-o key=value" syntax. The only problem I can
>> forsee is that command lines could get ridiculously long…
>>     
>
> But, I don't see why his script couldn't scp or whatever a generic
> screenrc to the target system's /tmp directory, e.g., prior to invoking
> screen and issue a 'screen -c /tmp/screenrc' and possibly remove it when
> he's done. I mean, doesn't he have write access anywhere on his server's
> file system..? Does that make sense?
>
> CJ
>
>   
Hello,

Based on the discussion and clues you all have given, I have solved the
issue :-) What I have done

[1] scp a copy of .screenrc to remote server
[2] ssh to the remote box and start screen
[3] rm the .screnrc before logout.

All these are automated with expect script. Here is the code I am using
in my ssh manager script

` ` `
expect -c '
#for debug
#exp_internal 1
log_user 0

#Placed .screenrc on the remote server
spawn scp "/home/admin/.screenrc" '$ssh_Server':'$screenrc_location'
expect "*assword:"
send '$PASSWORD'
send "\r"
interact

#start screen through ssh on remote server
spawn ssh '$ssh_Server' -t LANG=en_US.UTF-8 && TERM=xterm &&  "screen -c
'$screenrc_location' -aUS '$ssh_Server' -dR bash -l ||ssh '$ssh_Server'"
expect "*assword:"
send '$PASSWORD'
send "\r"
interact

#Delete .screenrc before logout
spawn ssh '$ssh_Server' rm -f '$screenrc_location'
expect "*assword:"
send '$PASSWORD'
send "\r"
interact
'
` ` `

Hope this is helpful.
Todo - checking if screen is installed in the remote server before scp ;
if not then give a warning and exit.

Thanks to all of you for your support.

-- 
জয়দীপ বক্সী





reply via email to

[Prev in Thread] Current Thread [Next in Thread]