Page 1 of 1

GNU screen: "-X: unknown command 'hardcopy -h'

Posted: Wed Aug 04, 2010 2:08 pm
by ^rooker
[PROBLEM]
I've finally discovered that GNU screen is not only good handling persistent sessions, but you can also remote-control a screen session by sending commands to it.

I wanted to take like a "screenshot" of a runnign session, by using the screen command "hardcopy" with a target filename, like this:

Code: Select all

screen -S "session_name" -X 'hardcopy "/tmp/test.log"'
Unfortunately, I received the following error message in the target session:
-X: unknown command 'hardcopy "/tmp/test.log"'
However, without arguments, it worked fine:

Code: Select all

screen -S "session_name" -X 'hardcopy'
[SOLUTION]
If you're sending a screen command with arguments, you must not use quotes. So the right commandline call is:

Code: Select all

screen -S "session_name" -X hardcopy "/tmp/test.log"
Voila!

TIPP!
Using hardcopy like this is perfect for monitoring background processes without giving someone shell-access, but rather dump the hardcopies to a path accessible over the network, so users can monitor things without being able to break anything. ;)