Observation of another process

Here's a hypothetical scenario: I am running a test script on some hardware attached to block A, to which I have root access. This test script requires minimal user input (toggle the switch every half hour or so). After about an hour and a half during the testing process, I understand that this script lasts a very long time, up to eight hours. Box A is in a very cold, loud server room, which is usually not so fun to physically occupy. Box B is in my office, where I have a beautiful comfortable chair and an endless supply of hot pockets. I want some way to track the output of a process running in field A from an ssh session in field B, so I know when to flip the switch, but I don't want to restart the testing process. If I knew what would start with the test taking so long, I would just pass its output to the log file and pull this file out of my B ssh session. If I know the PID of the process running in field A, is it possible to observe the execution of this process from another session?

Of course, I could just run vnc on field A and enter field B to look at the result, but this defeats the goal of this hypothesis, which is to learn more about how pipes, stdout and output are handled in general in a Linux environment.

Thoughts?

+7
linux pipe stdout
source share
2 answers

You might want to check expect. This is useful for automating these kinds of interactions.

You can also redirect the output of the script file to a file and control the specified file from another ssh session. I bet the brain guys on stackoverflow can name about 6 other ways to do this too. :)

0
source share

All Articles