Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So here's the setup:

I have a remote computer running a program directly in CLI from user account NN. If I SSH into the same user account NN, is it possible to see the output of the program running in the first user account instance from the second instance?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Unless the program is logging its output into a file, I'd say "no, not directly".

However, there is a way of achieving what you want. Use screen, which is a virtual console multiplexer:

http://en.wikipedia.org/wiki/GNU_Screen

(You can also use tmux which is more modern, but I'm not familiar with that so my answer will talk about screen).

Once you get screen installed:

  • Log into the remote system.
  • Start screen (just type screen, then read the intro screen, press space).
  • You'll see what looks like a standard command prompt. It is, however it lives inside one of screen's virtual consoles.
  • Start your program here.
  • When you want to leave your program working and log out, first "detach" screen. This "detaches" it from your actual terminal but screen (and the program contained inside it) continue running. The program thinks it's connected to an actual terminal so it will see no difference. To do this, press ctrl-a, then d (ctrl-a is screen's control prefix). You'll go back to a command prompt.
  • To reconnect to a running screen instance, type screen -rd. This will bring back screen and your running program.

You can of course detach and then log out entirely. When you log back in, you just screen -rd to get your "session" back.

Screen can do a lot more than that, you can have multiple "consoles" open, switch between them, copy and paste data, and even use split views and fancy stuff like that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.