Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Wise monks,

I've been spending my time recently working upon a new revision of IPC::System::Simple, a module designed to take the headache out of calling external commands. Unfortunately, I've hit a snag under Windows.

My Windows system (WinXP, ActivePerl 5.8.8) appears to assign a value of 1 << 8 to $? upon failure to start a process. The following example demonstrates this:

system("this_command_does_not_exist",1); printf("raw: %d ; apparent exit: %d\n",$?, $?>>8);

Unfortunately, this is indistinguishable from the command running to completion and returning an exit status of 1. Not being able to tell the difference is a very bad thing. There's also a troublesome error message that is printed ('...' is not recognised as an internal or external command) that I assume is from the Windows shell, and ideally I'd love to supress the printing of this message.

Using the multiple argument version of system does not alter these results.

I'm sure there must be a way under Windows to tell if a command did not start, and it's probably something simple, but I'm at a loss to find it.

Any tips and pointers would be greatly appreciated.

Update: This problem isn't exactly unique to Windows. When using single-argument system() under Unix with shell meta-characters, the result in $? reflects the exit value of the shell, which returns 127 on a failure to find the command. This is indistinguishable from a successfully executed command returning an exitval of 127.


In reply to $? set to strange values on failure under Win32 by pjf

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found