Xhings has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
This is my first post.
I am trying to get the output of an executable in a file. This worked fine with Win2003 but on win2008 server due to compatibility issues, I changed the settings to win2003 SP1 for the executable to run. Honestly I am working on 2008 for the first time.
I see that the out put is getting forked in a new cmd prompt and exits after execution.Is there a way I can get the o/p from this forked window?
Error from the below program in my output file is "child exited with value 0".I am opeing a Dir, running tool.exe for each of the file in side it and spooling output to my file.
Thanks Xhings
@files = readdir DH; open STDOUT, '> '.$Location2.'\ProcessedFilesInDir.txt'; foreach $file (@files) { $file1 = "tool.exe [- options]"; system ($file1) == 0 or die "system @args failed: $?"; if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($ +? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; } } close STDOUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to get output from a forked cmd prompt?
by ikegami (Patriarch) on Jan 21, 2010 at 08:26 UTC | |
by Xhings (Acolyte) on Jan 21, 2010 at 09:18 UTC | |
by ikegami (Patriarch) on Jan 21, 2010 at 20:16 UTC | |
|
Re: How to get output from a spawned cmd prompt?
by tokpela (Chaplain) on Jan 21, 2010 at 10:16 UTC | |
by BioLion (Curate) on Jan 21, 2010 at 11:17 UTC |