bugGNU Screen - Bugs: bug #32623, Problem with stuff command

 
 

bug #32623: Problem with stuff command

Submitted by:  None
Submitted on:  Mon 28 Feb 2011 12:18:05 PM UTC  
Votes:  60  
 
Category: Program LogicSeverity: 3 - Normal
Priority: 5 - NormalStatus: Duplicate
Privacy: PublicAssigned to: None
Open/Closed: ClosedRelease: 4.0.3
Fixed Release: NonePlanned Release: None
Work Required: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 02 Feb 2012 02:41:42 AM UTC, comment #7:

Thanks Ward!

Sadrul Habib Chowdhury <sadrul>
Project Administrator
Wed 01 Feb 2012 08:50:38 PM UTC, comment #6:

I've just checked against git head as of today (February 1st, 2012), and this bug is fixed.

Looking through the commit log, I think the fix is in this commit:

commit 39563832bbeab0c4e9ccb5925e3af3062f3d5f64
Author: Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
Date: Sat Aug 30 17:20:12 2008 -0400
Use the last created window as foreground window

Some commands don't work correctly if screen is started in daemon mode
and not attached/detached at least once. This happens because without
any attaches, no window is considered as the foreground window when
remotely executing a command without a display. In such a case, treat
the last created window as the foreground window, as suggested in
#10074.

Ward Vandewege <ward>
Wed 09 Nov 2011 11:43:40 AM UTC, comment #5:

I've the same problem, but the following works for me (Screen version 4.000.03jw4)

screen -dm -S test
screen -S test -p 0 -X stuff sometest
screen -S test -p 0 -X exec ...

I've scanned the manual
http://www.gnu.org/software/screen/manual/screen.html
about the -p option. The concept of 'preselection', what does it mean, cases of use is not explained enough to avoid the problem in future by the users.

Thanks for hint!

Anonymous
Mon 27 Jun 2011 03:15:35 PM UTC, comment #4:

I have included the -p switch to select the window, but it still doesn't seem to work.

Dana Kashubeck <dmkash>
Mon 27 Jun 2011 03:12:44 PM UTC, comment #3:

After starting screen with 'screen -dm', if you need to do something, you should preselect a window using the '-p' argument. For example:

screen -dm -S test
screen -S test -p 0 stuff sometest
screen -S test -p 0 exec ...

Sadrul Habib Chowdhury <sadrul>
Project Administrator
Sun 26 Jun 2011 03:10:23 AM UTC, comment #2:

I'm having this exact problem running version 4.00.03, however the workaround listed below doesn't work for me. This is on Mac OS X 10.6.8.

Dana Kashubeck <dmkash>
Thu 21 Apr 2011 09:07:12 AM UTC, comment #1:

This issue seriously limit's screen automation. Moreover the 'stuff', 'exec', 'kill' -X commands.
I'm reproducting this problem on FreeBSD 6.4-STABLE and Linux 2.6.26-2-686-bigmem.

I've get to a workaround - reattaching the screen using 'screen -r' and detaching makes the screen session back controllable.

Example of problem reproduction and workarounds

"I want to spawn 'man ls' and leave running in a screen session"

#10 Create screen session (assume no 'test' sessions exist)
$ screen -d -m -S test
#20 ...but the following will have no effect no mater how many
# times repeated ('stuff' also fails):
$ screen -S test -X exec man ls <RETURN>

#30 But reattaching (as bg job to keep control) and detaching...
#BUG? But sometimes no screen is available to atach to!
$screen -S test -r & sleep 2 ; screen -S test detach <RETURN>
# ...will make the screen controllable!

#40 Now, it works!
$ screen -S test -X exec man ls <RETURN>

So workaround is like this:
$ screen -d -m -S test; screen -S test -r & sleep 2 ; screen -S test detach; screen -S test -X exec man ls

But if I want to spawn screen and leave it running with 'man ls' on a remote machine using a script that is calling ssh the key workaround part 'screen -S test -r' will not succeeed because "Must be connected to a terminal", even 'ssh -t', 'ssh -tt' will not help.

So, I spawn ssh in local screen and control this screen in order to execute desired remote commands via ssh. To spawn command in a local screen from script I need to use the above workaround.
Finally the local obolete session should be closed but single -X kill command has no effect... somehow repeated twice succeeds

$ screen -m -d -S test;sleep 2;screen -S test -r&sleep 1;screen -S test -X detach;screen -S test -X exec ssh user@rmachine; sleep 4;screen -S test -X stuff "screen -m -d -S test;screen -r&sleep 1; screen -S test -X detach; screen -S test -X exec man ls"$'\x0D'; sleep 2; screen -S test -r&sleep 2;screen -S test -X detach;echo killing;screen -S test -X kill; screen -S test -X kill

Anonymous
Mon 28 Feb 2011 12:18:05 PM UTC, original submission:

After have created a screen with the option -d -m to detached it at the creation, it is impossible to use the command -X stuff on this screen.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ward (Posted a comment)
  • -unavailable- added by sadrul (Posted a comment)
  • -unavailable- added by dmkash (Posted a comment)
  • -unavailable- added by dmkash (I would like to know when this is fixed because I really want to be able to script the launching of screen sessions.)
  • -unavailable- added by dmkash (Voted in favor of this item)
  • -unavailable- added by jitsumi (Voted in favor of this item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 60 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 02 Feb 2012 02:41:42 AM UTCsadrulStatusNone=>Duplicate
      Open/ClosedOpen=>Closed
    Sun 26 Jun 2011 02:49:41 AM UTCdmkashCarbon-Copy-=>Added -unavailable-
    Sun 26 Jun 2011 02:48:47 AM UTCdmkashCarbon-Copy-=>Added dmkash
    Wed 02 Mar 2011 12:58:25 PM UTCjitsumiCarbon-Copy-=>Added jitsumi

    Back to the top


    Powered by Savane 3.1-cleanup1