This illustrates, in addition to security issues, why all system commands in any script should be prefaced by their full path.
I used to be in that camp, but I've found that it causes portability problems. We have a pile of legacy code that runs on many different machines. Some of the system calls use absoulte paths, and this causes trouble when common programs migrate between /bin, /usr/bin, /usr/local/bin, and other places on various versions of Solaris, Linux, Irix, etc...

For a while, I tried to maintain a config section with the absolute paths to every executable I might want to use. That didn't seem to help matters, because the config has to be tweaked all the time. What I really want is to be able to drop my script on a random machine and have it work with the minimum of fuss.

I've been thinking that a better solution might be to set $ENV{PATH} explicitly (possibly to different value depending on the OS), and then avoid using absolute paths whenever possible. Has anyone been there and brought back some advice?

System calls are also not very portable, as ps -ef won't work on the BSD versions of ps and ps aux will fail on the solaris versions.
ps is just pathological. If you need that kind of information out of the system, you're in for pain one way or another.

In reply to Re: Re: Why system calls suck. by no_slogan
in thread Why system calls suck. by japhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.