shan_x@jhuvms.bitnet (07/19/90)
======================================
The following perl script calculates disk space used by all users.
If I run it interactively, it works fine. But if I put it in "crontab",
it runs but doesn't output anything. It seems if "cron" runs it,
"open(IN, 'quot|')" doesn't work. I really can't figure out what is
wrong with it. Any help is greately appreciated.
Reply here or send it to "shan@sphunix.sph.jhu.edu".
I have perl3.0 at patch 18 in DECsystem 3100.
--Shan
#!/usr/bin/perl
chdir("/user/admin/shan/.acct")||die "can't change dir";
open(OUT,'>test.out')|| die "can't open output";
open(IN,'quot|')|| die "Can't open quot pipe\n";
select(OUT);$|=1;
while(<IN>){
chop;
s/^\s*//;
next if /\/+/;
($disk,$user)=split('\s+',$_,2);
$dusage{$user} +=$disk;
}
foreach $user (sort keys %dusage){
print OUT "$user $dusage{$user}\n";
}
close(OUT); lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/19/90)
In article <5859@jhunix.HCF.JHU.EDU> shan_x@jhuvms.bitnet writes:
: ======================================
:
: The following perl script calculates disk space used by all users.
: If I run it interactively, it works fine. But if I put it in "crontab",
: it runs but doesn't output anything. It seems if "cron" runs it,
: "open(IN, 'quot|')" doesn't work. I really can't figure out what is
: wrong with it. Any help is greately appreciated.
If you throw in a line at the top that says something like
$ENV{'PATH'} = '/bin:/usr/bin:/etc:/usr/etc:/usr/ucb';
(or whatever) I bet it would work better. cron doesn't keep much of a PATH.
Another place people get in trouble is running programs that want a
controlling terminal, though I don't think that's your problem.
Larry