
# from Donn # on Thursday 29 March 2007 10:51 am:
Just paste to a shell. What I wrote was a command and script.
I made a file out of it to allow me to rerun it etc. The output goes to the shell, but after a while it gets too long and one cannot scroll up to copy it all. Thus my need for a file output.
So it works, but quits working when you redirect the output? That's not a problem in my code and I can't see what's wrong from here.
Where did I lose you?
You didn't, bar my total non-clue about perl.
I don't think you're having any perl errors.
perl -e 'my $pid = shift; while(1) { open(my $fh, "<", "/proc/$pid/statm") or die; my $data = <$fh>; chomp($data); print join(" ", time,map({$_ * 4} split(/ /, $data))), "\n"; sleep(1); }' $(pidof inkscape) > logfile
Does not work. I actually tried this one too. The logfile is blank. I tried >> as well, to no avail.
Sorry, but "does not work" is not an error message I can parse.
Results in: scripts:$ ./eric2log $(pidof inkscape) > logfile ./eric2log: line 3: syntax error near unexpected token `(' ./eric2log: line 3: ` my $pid = shift(@ARGV);'
Undent the shebang! If you just pasted from e-mail, you have to start the #! on the first character of the first line or your shell will try to pretend it is a bash script.
scripts:$ perl eric2log $(pidof inkscape) > logfile
Note, you'll get the error message "Died" when the statm file isn't available. This means either at the very beginning (means you don't have inkscape running) or the very end (means you closed inkscape.)
--Eric