Shell script - System Check... What's wrong?

H

hypernatic.net

Guest
Hi I made a script that keeps me uptodate of what happens on my server:

Here is the shell part:
#!/bin/sh
###################
# (C) 2002 hypernatic.net
###################

mailq >spamlist.txt
locate mp3|locate .r01 >warezlist.txt
ps aux >psauxlist.txt

./syscheck.pl

rm -f *.txt

Now the perl script that mails it all
#!/usr/bin/perl
###################
# (C) 2002 hypernatic.net
###################

open (mque,"./spamlist.txt");
@mque= <mque>;
close (mque);

open (warez,"./warezlist.txt");
@warez= <warez>;
close (warez);

open (@psaux,"./psauxlist.txt");
@psaux = <@psaux>;
close (@psaux);

print "@psaux";

# Open The Mail Program
open(MAIL,"|/usr/sbin/sendmail -t");

print MAIL "To: user\@host.com\n";
print MAIL "From: root\@localhost (SysCheck Daemon)\n";
print MAIL "Subject: SYSCHECK REPORT\n\n";
print MAIL "################################################################################\n";
print MAIL "|------------------------------[ SPAM REPORT ]------------------------------|\n\n";
print MAIL "@mque\n\n";
print MAIL "|------------------------------[ SPAM REPORT ]------------------------------|\n\n";
print MAIL "################################################################################\n\n";
print MAIL "|-----------------------------[ WAREZ REPORT ]------------------------------|\n\n";
print MAIL "@warez\n\n";
print MAIL "|-----------------------------[ WAREZ REPORT ]------------------------------|\n\n";
print MAIL "################################################################################\n\n";
print MAIL "|---------------------------[ PROCESSES REPORT ]------------------------------|\n\n";
print MAIL "@psaux\n\n";
print MAIL "|---------------------------[ PROCESSES REPORT ]------------------------------|\n";
print MAIL "################################################################################\n";
close (MAIL);

Now for some reason, it WONT send me the @psaux....

Does anyone know WHY?
 
hypernatic.net said:
open (@psaux,"./psauxlist.txt");
@psaux = <@psaux>;
close (@psaux);

open (psaux,"./psauxlist.txt");
@psaux = <psaux>;
close (@psaux);

should fix it :p
 
Hi,

Ooops, Homer forgot to remove the @ in the closing fle hanlder in his fix. You will still need to fix the "close (@psaux)" part.

open (@psaux,"./psauxlist.txt");
@psaux = <@psaux>;
close (@psaux);

Should be:

open (psaux,"./psauxlist.txt");
@psaux = <psaux>;
close (psaux);

Just do it like you do the other's. The file handler is not an @array. There are better ways to do this, but this should work or that part of reading the file contents anyway.
 
Top