Punto has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

I saw a lot of nodes about running a program on the background, but is there any way to 're-attach' the program that's on the background, to use it on the terminal again? (like the /detach command on BitchX)

I'm looking at the bitchx code, but it's too ugly, and I want to use it for a perl script. I see something about fork(), an ipc socket, and a 'screen type program', but I'm missing something.

thanks..

Replies are listed 'Best First'.
Not really a perl question . . .
by Fletch (Bishop) on Oct 29, 2001 at 10:10 UTC

    Check if screen is installed on your system. It's a program that lets you talk to multiple programs running on different ptys and switch back and forth between them. It will also allow you to detatch from the session and then reattach later and get back in touch with what you left running. See http://www.gnu.org/software/screen/ for more details.

    You could do something similar in perl, but a) you'd be reinventing a wheel that already works fine, and b) it involves some deep UNIX mojo to do correctly.

Re: re-attaching?
by arabella (Acolyte) on Oct 30, 2001 at 07:34 UTC
    If you're using *nix you should look at the "fg" command. This is an internal command provided by most shells.