On Tue, Oct 18, 2011 at 02:20:53PM -0700, Russell Johnson wrote:
> sub writetemp {
> open (NEWFILE, ">/tmp/$0.count") or die $!;
> print NEWFILE "$product{name}.value $product{value} $date";
> close (NEWFILE);
> }
>
> This works like a champ when I run the script from the command line.
>
> But when I run the script from roots cron, no output file is produced. I've
> also tried producing the file in a subdirectory within the /root home
> directory, with the same results.
>
> Anyone have any ideas?
It doesn't die?
Are you sure it runs? ie, does the root crontab have the proper path elements
for this to function?
Check the return code from print. As in:
sub writetemp {
open (NEWFILE, ">/tmp/$0.count") or die $!;
my $ok = print NEWFILE "$product{name}.value $product{value} $date";
if ( ! $ok ) {
print STDERR "error on print to file: $!\n";
}
close (NEWFILE);
}
or print NEWFILE "$product{name}.value $product{value} $date" or warn "$!";
You may also set $| (autoflush) to true in case there's some weirdness in
output buffering.
Shouldn't be but ...
--
Michael Rasmussen, Portland Oregon
Other Adventures: http://www.jamhome.us/ or http://westy.saunter.us/
Fortune Cookie Fortune du jour:
It's a long way to go when you don't know where you're going.
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug