Basically I've set up a few Raspberry Pis running different programmes, and I'd like to see what is being outputted on them. I can obviously connect via SSH, but that's a new tty session. Tried googling it, but I think my terminology is a little odd!
-
Your terminology is a little odd yes :). Could you give an example so we can understand what you mean? – terdon Aug 27 '13 at 12:19
-
So I've got a Bash script running on the Raspberry Pi, and I want to remote login and view the output of that Bash script remotely. The Bash script is requiring user input on the Raspberry Pi. Like when I access via SSH it's a new session, rather than monitoring what's happening on the physical device.. – Elliot Reed Aug 27 '13 at 12:24
-
Look for "process standard output" or "proc linux stdout" (eg see [here](http://unix.stackexchange.com/questions/15693/see-the-stdout-redirect-of-a-running-process)). This is also [relevant](http://unix.stackexchange.com/questions/14730/view-stdout-for-another-pts) (monitoring a terminal). – Ярослав Рахматуллин Aug 27 '13 at 12:58
-
If you're running something interactive, you might want to start it in a [screen](http://en.wikipedia.org/wiki/GNU_Screen) session: http://superuser.com/a/454914/223699. You could then attach to the screen to see what is going on. – SlightlyCuban Aug 27 '13 at 20:01
2 Answers
try screen:
Logon to a Terminal and type apt-get install screen to install it.
Start screen by typing screen.
Tap Enter to get past the welcome screen.
start a process, for example a slow download:
curl --limit-rate 5K \
http://archive.raspbian.org/raspbian/dists/wheezy/main/binary-armhf/Packages
Press ^ad - Ctrl+a (Release Buttons) d - to detach.
Close the terminal.
logon as the same user (via SSH if you like) and type screen -r to resume.
screen can do a lot more, check out man screen.
As a side note, if you want your process to start on boot you should consider using an init script and make your process write logfiles.
- 166
- 4
-
Four years later and I've accepted this (apologies for being somewhat late!). Thanks to you however I now use screen all the time :) – Elliot Reed May 08 '17 at 15:33
-
5 years after that i read your comment :D - i switched to `tmux` in recent years. if you like screen i would recommend trying it – Florian F Feb 08 '22 at 12:43
As far as I know, there is no way of observing the output of a command run in a separate shell. Each shell (bash , for example) instance is a separate entity and you cannot communicate with it from a different shell.
The only way to monitor output would be to have your command save its progress in a file and then monitoring that file. For example, on the Pi:
some_command > some_file
or, to monitor standard error instead of standard output:
some_command 2> some_file
You can then watch the progress from another computer by running
ssh user@pi tail -f /path/to/some_file
- 52,568
- 14
- 124
- 170