http://qs321.pair.com?node_id=67099

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

This has to do with my music program.

My program is supposed to call system() in an endless loop. I want the user to be able to talk to the program (skip track, quit etc...), but if I run the program with &, my script assumes the program has quit and runs it again. How do let the user talk to my script while it is system?

Thanks

Replies are listed 'Best First'.
Re: Interacting while in system
by Yohimbe (Pilgrim) on Mar 26, 2001 at 09:15 UTC
    instead of calling system() use open (FOO, "|$program) to run the program as a subprocess. Anything you print to FOO will be sent the the stdin of $program. $program, if say a perl program can do while (<STDIN>) { &process_command($_);}
    --
    Jay "Yohimbe" Thorne, alpha geek for UserFriendly
Re: Interacting while in system
by chromatic (Archbishop) on Mar 26, 2001 at 09:17 UTC
    Yohimbe has the truth of it. Look to perldoc perlipc on your system for more information. (Since you're using a shell that supports backgrounding, you probably have enough Unix that opening a pipe to the program will work. Lucky!)