Hosting Discussion

Hosting Discussion (https://www.hostingdiscussion.com/)
-   Website Development & Design (https://www.hostingdiscussion.com/website-development-design/)
-   -   Shell script - System Check... What's wrong? (https://www.hostingdiscussion.com/website-development-design/67-shell-script-system-check-whats-wrong.html)


hypernatic.net 01-23-2002 11:21 AM

Shell script - System Check... What's wrong?
 
Hi I made a script that keeps me uptodate of what happens on my server:

Here is the shell part:
Quote:

#!/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
Quote:

#!/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?

Homer 01-26-2002 07:03 AM

Re: Shell script - System Check... What's wrong?
 
Quote:

Originally posted by hypernatic.net
open (@psaux,"./psauxlist.txt");
@psaux = <@psaux>;
close (@psaux);

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

should fix it :P

Tim Greer 02-17-2002 12:48 AM

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.


All times are GMT -6. The time now is 11:06 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0