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

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

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

Post 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. ;)
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply