note
etcshadow
It depends on what the program is that you are running... but another possible issue is this: When running a command with <code>system()</code>, it is hooked up directly to your terminal, both for output and input... just as though a user had run that command at a shell prompt. When running a command with backticks, the input (as well as stderr) is still hooked up to the terminal, but the output stream is no longer the terminal... it is a pipe back to the parent (perl) process.
<p>
Why does this matter? Well some programs will produce different output (or just generally work differently) if they detect that they are attached to a terminal than if they are not. For example, at least on many linux variants (can't speak for all *nixes), the <code>ps</code> command will format it's output for a terminal (it sets the the output width to the width of your terminal) if it sees that it is outputting to a terminal, and otherwise it will truncate its output width at 80 characters. Likewise, <code>ls</code> may use terminal escape code to set the color of file-names to indicate permissions or types. Also, <code>ls</code> may organize its output into a pretty looking table when writing to a terminal, but make a nice neat list when NOT writing to a terminal.
<p>
Anyway, an easy way to check this out with your program is via a [http://rhols66.adsl.netsonic.fi/era/unix/award.html|useless use of cat] such as this:
<code>
[me@host]$ command
...
[me@host]$ command | cat
...
</code>
<p>
And comparing the differences in the output. You can see the same thing (sorta) happening between <code>system</code> and backticks with this (which simply checks to see if the output stream is attached to a terminal or not):
<code>
[me@host]$ perl -e 'print `perl -le "print -t STDOUT"`'
[me@host]$ perl -e 'system q(perl -le "print -t STDOUT")'
1
[me@host]$
</code>
<p>
As a shameless personal plug, I've actually written a [id://299012|node] about how you can fool a process into thinking that it is connected to a terminal when it is not. This may not be of the utmost use to you in fixing your problem... but it is apropos.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-296575">
<code>
------------
:Wq
Not an editor command: Wq
</code>
</div></div>
380670
380670