dpuu has asked for the wisdom of the Perl Monks concerning the following question:
Even after a perfect cleanup, this code would leave much to be desired: it is not portable. It doesn't even work under Cygwin! Another problem is that strace can't be invoked recursively, which could be an issue with recursive makefiles. I was wondering if, hidden inside one of the various Run::* modules (or elsewhere), there is simpler, more portable, way?use POSIX 'tmpnam'; my $cmd = "cat /dev/null"; my $trace_file = tmpnam; system "strace -f -e trace=open -o $trace_file $cmd"; my %files = (); open TRACE, "<$trace_file"; while (<TRACE>) { /^open\("(.*)", O_/ and $files{$1}++; } close TRACE; unlink $trace_file; print join "\n", sort keys %files;
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting Files used by a shell command
by TVSET (Chaplain) on Jul 14, 2003 at 22:35 UTC | |
by dpuu (Chaplain) on Jul 15, 2003 at 00:08 UTC |