As other people have said, the command history is a feature of the shell, and only stores interactive commands, not non-interactive ones, such as those launched from a Perl system() function call.

To expand upon Corion's answer - using truss (or analogues) will probably not get you what you want. What it will get you is a list of system calls (that is, kernel level system calls such as getuid() or chmod() ) that the process executes. If you truss the Perl program that executes the system() function (function as distinct from system call), you will get the system calls executed by the Perl binary, the shell called to execute your commands, and your commands. This might be too many trees to keep seeing the wood.

As to accounting, you can do that (process accounting, see the link Bronto provided), but for just logging what your Perl script does, this might be a bit over the top as well.

If you want to keep track of what the script does when, you could always write a wrapper around system() that logs the command executed to a file and then executes the command normally:

sub my_system { my @command = @_; print LOGFILE join " ", @command; warn "This code is untested."; system (@command); }

CU
Robartes-


In reply to Re: perl, system() calls, and shell history by robartes
in thread perl, system() calls, and shell history by silent11

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.