(re)attach process?

arri

Registered
sorry, this must be really basic;

i use an old g3pb as a sort of juke-box. i use mpg123 to play files and playlists, but i usually control it from behind my desk. (another machine)

but i want to be able to 'detach' the (mpg123) process on the g3 from the terminal session om the powerbook on my desk, and later attatch to it again (if those are the right terms)

i could use mpg123 like this "mpg123 ... &" and then exit from that shell...
but how can i then later attach it again?

hope you girls and boys understand what i mean.
i figure this is really basic unix stuff, and that's exactly why i want to know;
it will be very usefull for infinite other purposes..

thanks
arri
 
fg JOB_ID

fg stands for "foreground"

Forgot to say...
to list jobs

jobs

example

host:~ user$ sleep 100&
[1] 16245
host:~ user$ jobs
[1]+ Running sleep 100 &
hostl:~ userl$ fg 1
sleep 100
^C
host:~ user$

type help at your bash prompt to see a list of builtin commands, then use help COMMAND to get a quick description.

host:~ user$ help fg
fg: fg [job_spec]
Place JOB_SPEC in the foreground, and make it the current job. If
JOB_SPEC is not present, the shell's notion of the current job is
used.
 
thanks auser,
you're solution is what i thought'd be the way, but it only works as long as you're in the same 'session'. once you exit that shell (or logout), i never manage to do as you suggest.

maybe i have to reformulate my question;
i want to exit a session with running commands, to later login to that session again..

i found some information about redirecting input and output of processes, and have to idea that that's the direction to search for a solution...
 
You want to use a program called "screen" then, type "man screen" at the prompt and become enlightened. ;-)
 
WOW!
yes, i am enlightened!

thanks a lot!
that's exactly what i was looking for.
and as i sayd in my initial post; this is going to be so usefull for many other purposes...

great!
 
Happy to help, In the old days I used to live in that program. My 1200 baud connection was flakey and it would suck to lose all my work when the line dropped ;-)

Screen would let me reattach and keep going.
 
i'd like to extend this thread a bit by sharing my findinds in this field.

i've been using screen almost permanently over the past years.
it has become standard practice to log into remote machines using screen-sessions

Code:
$> ssh -t hostname.tld screen -RD

so most of the time i re-connect to a running session rather than actually login in and creating a new session. very convenient.

but a feature i was missing very much, is the ability to split screen-windows vertically.
by that i mean: having two shells running side by side (left/right).
you can already split a screen-window in two horizontally split panes (top/bottom) and a patch exists for compiling a screen-binairy with vertical-split functionality, but it's quite a hassle and pretty buggy..

and that's when i found tmux.

tmux has pretty much the same functionality screen offers, but i find it to be much more stable and consistent. AND it as a built-in hor/ver split option.
next to that it's implemented in a server/client architecture, making it much more flexible.

on osx you can download sources here: http://tmux.sourceforge.net/ and compile a version of tmux yourself.
or you can use darwinports to install (an older version of) tmux.
 
Back
Top