Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: System() in list mode?

by anneli (Pilgrim)
on Oct 18, 2011 at 09:29 UTC ( #932098=note: print w/ replies, xml ) Need Help??


in reply to System() in list mode?

For output I get:
$PATH
env: bash: No such file or directory

Where's the issue here? This is the correct output; the first system didn't expand $PATH (which we all know we all know about now), and in the second, you changed $PATH to foo and I guess you don't have a binary called foo/bash! If your PATH contained bash, using env PATH=... will work just fine.

Anne


Comment on Re: System() in list mode?
Select or Download Code
Replies are listed 'Best First'.
Re^2: System() in list mode?
by 1337John (Initiate) on Oct 18, 2011 at 14:38 UTC
    What??? Of course it's the correct output for my code. But it's not what I want my code to do. Could you be so kind as to provide me with an example of appending to the PATH variable, then successfully running a script in a path with spaces in it, in one system() call?

      Alright.

      Here I'm prepending $HOME/dir to PATH, and executing a program named "program name", which happens to be in /home/anneli/dir (i.e. the path I prepended):

      $ pwd /home/anneli $ ls -F ./dir/ program name* $ cat dir/program\ name #!/usr/bin/env perl print "It works!\n"; $ cat eg.pl system('env', "PATH=$ENV{HOME}/dir:$ENV{PATH}", 'program name'); $ perl eg.pl It works! $

      I hope this helps. We do the necessary expansion of HOME and PATH on our side, before sending them through to the (non-expanding) multi-argument system call.

      Anne

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2015-07-29 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls