How is the command executed if the shell is not invoked?
By asking to system execute the specified program instead of asking the system to execute /bin/sh.
Why does adding a redirect to /dev/null increase the complexity enough to invoke the shell?
There's no point in including an entire shell in Perl. I don't know exactly what part of shell command parsing is implemented in Perl.
Finally, what method is used to execute the command if I had instead used perl's system() function instead of the backticks?
system($cmd), exec($cmd), open(my $pipe, '-|', $cmd) (and its 2-arg form) and open(my $pipe, '|-', $cmd) (and its 2-arg form) work the same way as `$cmd` (aka qx`$cmd` aka readpipe($cmd)).
system($prog, LIST) where LIST returns at least one scalar won't invoke the shell.[1]
system({ $prog } $prog, LIST) won't invoke the shell.
- It can in Windows.
-
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.
|