IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 1 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Spawning multiple processes under Windows / Perl
I'm trying to automate some processing on a Windows
2000 server. The goal:

Watch a particular directory for batch files to show up.
Rename it to another dir, tacking on a time stamp.
Execute it.
Rename it to a "done" dir.

These batch files call an AFP spooling utility that is
strictly command line / STDIO IO programs, not creating desktop
windows.

I have a master batch file that I use to execute them,
which then does the final rename to the done dir.

I want to execute the master batch file in the background,
redirecting the STDERR and STDOUT to files.

I also want to execute it in the background, returning control
back to my perl script immediately so I can execute any more
that happen to be in the queue. Under Linux I would have used
the perl:

system("FULL_FILE_NAME_TO_EXECUTE 2>stderr.log 1>stdout.log &");

Modifying the logs to reflect the program being executed, of
course.

I orginally did all the by logging in via WinSSHD to the box,
but the WinSSHD has been implicated in some BLue Screens so
I am trying to knock it out of the picture.


If I was trying to do the work "byhand" under Linux I'd
play with fork and STDOUT/STDERR reopening, etc.

But I can't get it to work that way.

Is there some standard Windows untility that does this?

Any hints?

New system(1, @args)
The above is a hack for emulating & on systems that do not support it. It isn't well documented, but if you browse [link|http://www.perldoc.com/perl5.8.4/pod/perlport.html#Alphabetical-Listing-of-Perl-Functions|the guts] of perlport for its documentation of system you should find it.

I have also used IPC::Open3 and friends with varying degrees of success. I've had it work. I've had it fail. I'm not entirely sure what the boundary is between what works and what does not. It likely has improved since I had to deal with it. Try it.

If you still run into trouble, a root cause may be that on Win32 fork() and similar things sometimes get emulated using multi-threading. Which works fine as long as you are dealing with pure Perl, but then when you try to exec you've got a problem. If you really can't do what you want, the Perl that comes with cygwin may work better.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Thanks, works great for me.
New Re: Spawning multiple processes under Windows / Perl
[link|http://www.research.att.com/sw/tools/uwin/|http://www.research....om/sw/tools/uwin/]
looks like commercial support has ended but check the licence for whats available caveat I havnt used them myself yet
regards,
daemon
that way too many Iraqis conceived of free society as little more than a mosh pit with grenades. ANDISHEH NOURAEE
New Thanks, but no thanks
Got it working.
The less random crap I put on that computer the better.
I'm about to push for a system build to make it "clean"
again.
     Spawning multiple processes under Windows / Perl - (broomberg) - (4)
         system(1, @args) - (ben_tilly) - (1)
             Thanks, works great for me. -NT - (broomberg)
         Re: Spawning multiple processes under Windows / Perl - (daemon) - (1)
             Thanks, but no thanks - (broomberg)

Thanks for noticing.
42 ms