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;

In reply to How to get output from a spawned cmd prompt? by Xhings

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.