Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

an exe can be executed from cmd but wraping into perl fail to run

by kaka_2 (Sexton)
on Dec 16, 2014 at 17:10 UTC ( [id://1110519]=perlquestion: print w/replies, xml ) Need Help??

kaka_2 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Experts,

I have an application exe which run quite well from the cmd but when put it into thr simple perl file it does not return any output.

$a = `command.exe`; print $a;

Question is how to troubleshoot? what make it different when it is being executed from a perl file and not cmd.

any hint in this regard will be helpful.

Thank You. -KAKA-

Replies are listed 'Best First'.
Re: an exe can be executed from cmd but wraping into perl fail to run
by Anonymous Monk on Dec 16, 2014 at 17:21 UTC

    To see if your command is failing or exiting with a nonzero code, which usually indicates an error, try inspecting $? and $!. Or, even better, use IPC::System::Simple's capture, since that does the interpretation of $? for you.

      $? prints 0 and $! prints nothing.
Re: an exe can be executed from cmd but wraping into perl fail to run
by RichardK (Parson) on Dec 16, 2014 at 17:23 UTC

    print out the error code $? and see what you get.

    or use system

Re: an exe can be executed from cmd but wraping into perl fail to run
by Laurent_R (Canon) on Dec 16, 2014 at 18:29 UTC
    You did not say much about your executable application, so we don't know what it's doing. It could be that it is sending its output to STDERR instead of STDOUT, in which case you would not capture such output with the backticks.

    Also please tell us on which operating system you are doing that.

Re: an exe can be executed from cmd but wraping into perl fail to run
by soonix (Canon) on Dec 18, 2014 at 08:15 UTC
    Maybe the perl application changes the PATH or the working directory. You could find this out by trying the commands
    print `dir`; print `set`;
    If that's the case, you have to give the full path of your exe, e.g.
    $a = `C:\\where\\ever\\it\\is\\command.exe`;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1110519]
Approved by atcroft
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found