0

I have long commands to send to a detached screen. I used :

screen -x screen-name -p 1 -X stuff 'mycommand\n'

As inspired by this related post. It works, but if mycommand is very long I get the screen error :

remote control too long

I cannot cut the command in smalled bits. It is like:

( { script1.sh; script2.sh; } </dev/null &>/dev/null &)

with many scripts and mv operations between the scripts.

So, how could I make screen to accept these long command lines? Thanks for your help!

  • 1
    You can put any long command in a shell script with a short name and then pass the short name of the shell script to screen – HBruijn Sep 18 '19 at 18:16
  • @HBruijn yes I might end up doing that, tough given my number of processes it can become a bit messy... I am still considering my options :) – jeannej Sep 18 '19 at 19:11
1

Screen's stuff command does not run commands, it emulates typing. It sounds like you have a shell running in the screen session, which is reading what it believes to be typing and running it when it receives a newline.

So you can cut the command into small bits; you could send it one character at a time if you want. The shell inside the screen won't run it at least until you send the final character, the \n.

(That said, it's probably much easier to put the whole thing in a shell script file then either run or source it).

  • Thanks a lot, I didn't know that I could continue pasting in the same screen line as long as I do not send a \n! So that screen -x screen-name -p 1 -X stuff 'mycommand\n' and : screen -x screen-name -p 1 -X stuff 'myco' screen -x screen-name -p 1 -X stuff 'mmand\n' are equivalent – jeannej Sep 18 '19 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.