The answer is twofold :
- The mechanism of shell history is merely a convenience for the user - thus it makes no sense to add anything to the history list beyond what the user enters. Aliases for example are not stored in their expanded form.
So for that case, the answer is "No, the shell history does not store noninteractive commands".
- In principle, under most Unixy systems, it is quite easy to find out what OS calls any program makes by running the truss command, finding the relevant portions within the logfile is then an exercise left to grep and some guesswork. So, for the general case, the answer is "Yes, it is possible to record what system calls a program makes". Also consider that your admin might supply you with a custom version of Perl that records the arguments to system() in a logfile.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The
$d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider
($c = $d->accept())->get_request(); $c->send_response( new #in the
HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
| [reply] [d/l] |
I was courious as to weather system() calls made from perl get stored in a history file somewhere.
Nope, as your history file is maintained by your shell.
My question is, is it possible that my perl script's system() calls are being recorded or stored some where else by the shell, or possibly by an administrator?
Unless you have some kind of audit system for processes then most likely 'no'.
HTH
_________ broquaint
| [reply] |
/me digging in his own brain
AFAIR, it should be possible to configure a UNIX kernel to turn on system accounting: that way the kernel will log every call and, in particular, each and every command any user issues. By the way, it could slow down the OS on slow and/or busy machines.
I'm not sure I remember well, anyway. You really want to check what I'm saying.
Update: Aha! Got it! Check this!
Ciao! --bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
| [reply] |
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- | [reply] [d/l] |
In addition to what everyone else has said, I don't remember the Bourne shell having any sort of history mechanism. That is, unless someone made 'sh' a synonym for either 'ksh' or 'bash' (of which, I've seen both).
thor | [reply] |