Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Executing perl program from another perl program and capturing the output

by Loops (Curate)
on Nov 25, 2014 at 02:58 UTC ( #1108298=note: print w/replies, xml ) Need Help??


in reply to Executing perl program from another perl program and capturing the output

Hi there,

You don't want to use 8.3 names. You just need to pass each individual parameter to system as a list, instead of together in a string. That way the parameters are already divided up and not further split on space characters. Unfortunately system does not capture its output, but Capture::Tiny is to the rescue in that regard:

use Capture::Tiny ':all'; my @cmd = ( 'C:\program files\myprog\space invaders.exe', 'parameter 1', 'parameter 2 with spaces' ); my ($stdout, $stderr, $exit) = capture { system @cmd }; print "The return status was $exit\n"; print "The output was $stdout\n";
  • Comment on Re: Executing perl program from another perl program and capturing the output
  • Download Code

Replies are listed 'Best First'.
Re^2: Executing perl program from another perl program and capturing the output
by Anonymous Monk on Nov 25, 2014 at 03:14 UTC

    You don't want to use 8.3 names ...

    If they have anything resembling unicode you sure do want to use 8.3 if you got them :) otherwise you won't be able to read or execute that file

      Well, I'll have to take your word for that. If true, then Perl does not deserve to be used on Windows. Telling people to use 8.3 filenames at this stage of the game is a sad admission of defeat and a poor implementation.

        Well, I'll have to take your word for that. If true, then Perl does not deserve to be used on Windows. Telling people to use 8.3 filenames at this stage of the game is a sad admission of defeat and a poor implementation.

        Yeah, that statement is worthy of expletives Loops, but if we the win32 users don't despair, neither should you :)

        Since the beginning of windows, cmd.exe did not come with unicode by deafult... and cmd.exe is at the root of every application, its documented in perlport ... we users of win32 know there is always a little extra work to accommodate out platforms, we're better at portability programming than non-win32 programmers :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1108298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2021-04-17 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?