Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
What's weird is if I do command task on alpine directly on the command line, it runs just fine. It's only with perl I seem to have the problem.

What you type at the command line gets interpreted by whatever shell you have running at that moment. The shell may recognise built-in commands that don't exist as binaries in the filesystem. In some cases, commands can be both built-ins and exist as binaries in the file system, with (AFAIK) the built-ins taking precedence over the binaries in the PATH (again, I'm only talking about commands typed into the shell here). For example, when you type echo in bash, the shell will use its built-in instead of calling /bin/echo. You can get the binary if you explicitly run /bin/echo.

But if you explicitly want to access the shell built-in from Perl, the tricky thing is that Perl's system and similar functions may or may not run the command in a shell (/bin/sh!) for you depending on what arguments you give them. So, you'll need to be explicit about calling the shell, and the form I showed will prevent Perl from running a shell implicitly, and then we explicitly run zsh and give it a command to execute with -c, as if typed into the shell.

There is also a bit more about this in my node Calling External Commands More Safely.

A few edits for clarity.


In reply to Re^4: Can't exec "command": No such file or directory error by haukex
in thread Can't exec "command": No such file or directory error by nysus

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 browsing the Monastery: (5)
As of 2024-04-18 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found