Possible Duplicate:
sending text input to a detached screen
With reference to the answered question: Sending input to a screen session from outside
I am trying to write a script that will create a screen
and then stuff
input (in my case, UNIX commands) into the shell that I want it to execute.
Here's what I have till now:
$ screen -dmS new_screen bash
$ screen -S new_screen -X stuff "cd /some/path/
some_script_file.sh
" <--This new line is required to execute the above command.
$ # Note: See comments. We could insert the newline character instead of 'hard-coding' a newline string literal.
For some reason, the screen gets created fine and enters the bash
shell. But the cd
and some_script_file.sh
commands don't get stuffed to the screen's bash shell.
Now the really strange part is.. After I detach from the screen, re-execute the stuff command as below..
$ screen -S new_screen -X stuff "cd /some/path/
some_script_file.sh
"
and then attach back into new_screen. Now I see that the commands were correctly stuffed and executed in the bash shell inside screen.
Not sure where I am going wrong here, there seems to be any issue stuff-ing commands into a not as yet attached screen.
ENTER
word to signify you are done. Pretty sure you need to do the same with screen. – vgoff Nov 18 '12 at 06:05