> -----Original Message----- > From: Mason, Andrew [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 7:11 AM > To: [EMAIL PROTECTED] > Subject: Issuing multiple concurrent commands (to system) > > > Is it possible to issue multiple concurrent commands to system (for > instance) from within a perl script? > > If it is (and I strongly suspect that it must be) would someone please > be so kind as to suggest some terms or perl commands to look up. (I > suspect the term threading might appear but I don't want to start > barking up the wrong tree if I don't have to) > > I'm happy to research this but just don't know where to start. > > The reason I would like to do this is to speed up some reporting > scripts. Ie if I'm using a perl script to search multiple > locations for > a file, or issue a command on multiple machines it would be nice to > issue them all at once rather than wait for each to return. > > Also is it possible to make perl issue a command to system (again for > instance) and not wait for a returned value?
system() is basically: fork() exec() (in child) wait() (in parent) If the child isn't going to talk to the parent, and you want the parent to be able to do other things while the child is running, you need to do the fork and exec separately, without the wait. You can wait later if you need to reap the exit status of the child. perldoc perlipc says you can also use: system("foo &"); which would do: fork exec /bin/sh -c 'foo &' fork exec foo (/bin/sh exits) wait (reaps /bin/sh exit, but foo still running) Relevant docs in: perldoc -f fork perldoc -f exec perldoc -f wait perldoc perlipc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]