Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

by aitap (Curate)
on Nov 18, 2014 at 20:26 UTC ( #1107636=note: print w/replies, xml ) Need Help??


in reply to 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Wherever available, you should use LIST-style forms of command launching functions. For example, prefer system("rm", "-rf", @temp_directories) over system("rm -rf @unneeded"). The same goes for pipe-open, exec and so on.

This is because when Perl encounters a command which consists of a single string containing so called special characters it passes the whole string to the shell. And modern filesystems allow spaces in file names which are not getting escaped, and this is where your command breaks. Some filesystems even allow glob characters (like * [ ]). Even more fun: imagine creating a file called -rf ~ and trying to remove it by system("rm $filename").

Bad news: list form of open is not supported on Windows. Good news: list form of open2 is. And so is high-level IPC::Run (but I got some problems with binary files transferred via pipe when I used this module).

  • Comment on Re: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-03-28 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (69 votes). Check out past polls.

    Notices?