Backtics and System will start up a new program but it is modal - to get
back to the original script the spawned program must be closed.
Exec kills the original script when the spawned program starts up.
I want a script to throw off another script and go on with its business.
It would appear that Fork might the the answer, but so far RTFM'ing about
Fork is getting me even more confused.
Any other way?
Thanks
Tom W
perldoc -q background.
I would recommend IPC::Run.
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. b...@morrow.me.uk
Well, kind of. You can always run the external program in the background
(by whatever means your OS provides) in which case the shell will
return immediately after kicking off the background program.
>Exec kills the original script when the spawned program starts up.
That's what it is designed to do, yes.
>I want a script to throw off another script and go on with its business.
>It would appear that Fork might the the answer, but so far RTFM'ing about
>Fork is getting me even more confused.
fork() is really simply. You get two identical copies of your Perl
process except for their respective process id's and the return value of
their respective fork() calls.
One of them, usually the parent, you just let continue to run.
The other, usually the child, you replace immediately with the program
you want to run using exec().
jue
> Any other way?
Why any other way than fork() when fork() is the correct way?
Just call it and (in case of success) you have a new process.
Something like
if ( fork() == 0 ) {
print "This is the new process\n";
exec( 'new_script' );
}
print "Parent: Just spawned a new process\n";
creates a new process (if fork() returns 0 you're running in the
new process, if it returns anything else you're still in the old
process).
What are you getting confused about with fork()?
Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de
A Win32 solution is mentioned here:
In Unix, you could background the other script in
a subshell:
0 == system "(/path/to/other_script &)"
or die "system failed: $?";
But getting the return status of the backgrounded
task would be messy and you'd lose the control
and flexibility of the recommened IPC::Run or
fork solutions.
--
Charles DeRykus
If you use open with mode '-|' or '|-' it isn't messy at all: close
returns the return status. It also avoids the additional shell. You need
to take care about the input or output, which may add some
complications.
hp
True. I was just guessing from the OP's description "throw off
another
script and go on with its business", he just wanted a "spawn and
forget"
type background action. (with no interaction and possibly no concern
about status as well),
--
Charles DeRykus
Charles DeRykus