Results 1 to 5 of 5
okay, i have this perl script for SigX and im trying to put a new line into my crontab file in my /etc folder so that itll execute the perl ...
- 07-15-2005 #1Just Joined!
- Join Date
- Jul 2005
- Location
- Don't turn around...
- Posts
- 31
cronjobs and perl scripts
okay, i have this perl script for SigX and im trying to put a new line into my crontab file in my /etc folder so that itll execute the perl script every 2 miniutes. this is the line i added to the crontab file
im just wondering if i did the right thing, if not someone correct me. this isnt as easy as it was in windows lol.Code:0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /etc/SigX.pl >/dev/null 2>&1
im also posting the SigX script just so you can look over it and tell me if theres anything wrong with it, or if theres anything i need for it to run.
so thats it, im just looking for a little help, hopefully someone here has already done this and knows how to. thanks guys.Code:#!/usr/bin/perl # Credits : This script was created by and is currently maintained # by Victor Igumnov [lamer0@lamer0.com]. # # Legal Info : Copyright (C) 2003, Victor Igumnov [lamer0@lamer0.com] # # This program is free software. You may redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software # Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License # for more details. # $|=1; use CGI; use URI::URL; use LWP::UserAgent; #Set These my $CPU='temp3'; my $MOBO='temp2'; my $FAN='fan2'; $MYUPTIME = `/usr/bin/uptime`; $CPUNAME=`cat /proc/cpuinfo | grep '^model name' | head -1 | sed -e 's/^.*: //'`; ($CPUNAME)=$CPUNAME=~/^\s*(.*?)\s*$/; # trim head/tail at same time $CPUSPEED=`cat /proc/cpuinfo | grep 'cpu MHz' | head -1 | sed -e 's/^.*: //'`; $BOGOMIPS=`cat /proc/cpuinfo | grep 'bogomips' | head -1 | sed -e 's/^.*: //'`; $UNAME = `uname -sr`; #--PERCENTAGE OF MEMORY FREE--# $MEMPERCENT = `free | grep Mem | awk '{print (( \$3 -(\$6 + \$7) )/\$2)*100}'`; chop ($MEMPERCENT); $MEMPERCENT = sprintf('%.2f', $MEMPERCENT); #--MEMORY FREE--# $MEMFREE = `free | grep Mem | awk '{printf (\"%.0fg\", ( \$3 -(\$6 + \$7) )/1000)}'`; chop ($MEMFREE); #--TOTAL MEMORY--# $MEMTOTAL = `free | grep Mem | awk '{printf (\"%dMb\", \$2/1000 )}'`; chop ($MEMTOTAL); #--SCREEN RESOLUTION--# $RES = `xdpyinfo | grep dimensions | awk '{print \$2}'`; chop ($RES); #--DISKSPACE--# $HDD = `df | awk '{ sum+=\$2/1024^2 }; END { printf (\"%dGb\", sum )}'`; chop ($HDD); #--DISKSPACE FREE--# $HDDFREE = `df | awk '{ sum+=\$4/1024^2 }; END { printf (\"%dGb\", sum )}'`; chop ($HDDFREE); #--SCREEN RESOLUTION--# $RES = `xdpyinfo | grep dimensions | awk '{print \$2}'`; chop ($RES); chop($UNAME); chop($CPUNAME); chop($CPUSPEED); chop($BOGOMIPS); $RAMLEFT=$MEMTOTAL-$MEMFREE; $query = new CGI; $query->import_names('webform'); my $username = "BlackFox"; my $password = "********"; $DATA_2_SEND="Uptime: $MYUPTIME *<*"; $DATA_2_SEND .= "CPU: $CPUNAME *<*"; $DATA_2_SEND .= "MHZ: $CPUSPEED *<*"; # $DATA_2_SEND .= "BOGOMIPS: $BOGOMIPS *<*"; $DATA_2_SEND .= "OS: $UNAME *<*$MEMPERCENT% Ram Used | Total RAM = $MEMTOTAL | $ $DATA_2_SEND .= "Diskspace: $HDD Free: $HDDFREE *<*"; # $DATA_2_SEND .= "Screen Res: $RES"; $DATA_2_SEND .= "Currently Listening to: $XMMSSONG at $XMMSPOSITION/$XMMSTIME."; #print $DATA_2_SEND; my %form = (); %form =('username' => $username, 'password' => $password, 'data' => $DATA_2_SEND, 'Submit' => ''); my $ua = new LWP::UserAgent; my $curl = url("http:"); my $req = new HTTP::Request 'POST','http://sigx.yuriy.net/update.php'; $req->content_type('application/x-www-form-urlencoded'); $req->content($curl->equery); $curl->query_form(%form); $req->content($curl->equery); my $response= $ua->request($req)->as_string;
**edit**
also i try and run the SigX.pl file by typing "sh SigX.pl" in my console and this is the message i get.
Code:[blackfox@21-130 etc]$ sh SigX.pl SigX.pl: line 20: $: command not found SigX.pl: line 20: =1: command not found SigX.pl: line 22: use: command not found SigX.pl: line 23: use: command not found SigX.pl: line 24: use: command not found SigX.pl: line 27: my: command not found SigX.pl: line 28: my: command not found SigX.pl: line 29: my: command not found SigX.pl: line 31: =: command not found SigX.pl: line 33: =AMD: command not found SigX.pl: line 34: syntax error near unexpected token `=$CPUNAME=~/^\s*' SigX.pl: line 34: `($CPUNAME)=$CPUNAME=~/^\s*(.*?)\s*$/; # trim head/tail at same time' [blackfox@21-130 etc]$
- 07-15-2005 #2Linux Engineer
- Join Date
- Apr 2005
- Location
- Buenos Aires, Argentina
- Posts
- 908
Well, you will have to fix that script first..
Also:Did you know that you can simplify that to..0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,3 6,38,40,42,44,46,48,50,52,54,56,58 * * * * /etc/SigX.pl >/dev/null 2>&1
*/2 * * * * /etc/SigX.pl >/dev/null 2>&1
serzsite.com.ar
"All the drugs in this world won\'t save you from yourself"
- 07-16-2005 #3Just Joined!
- Join Date
- Jul 2005
- Location
- Don't turn around...
- Posts
- 31
clarification = i dont know what the **** im doing, thats why im trying to ask for help. if i knew how to fix it, i wouldnt be posting asking for help...
- 07-18-2005 #4Linux Engineer
- Join Date
- Apr 2005
- Location
- Buenos Aires, Argentina
- Posts
- 908
Wait a sec, that's a Perl script and you're using "sh script", treating it as it if was a shell script.
Try /usr/bin/perl SigX.pl instead.serzsite.com.ar
"All the drugs in this world won\'t save you from yourself"
- 07-21-2005 #5Just Joined!
- Join Date
- Jul 2005
- Location
- Don't turn around...
- Posts
- 31
okay, that helps a bit, i didnt quite realize what the sh command was, so heres the latest.
*edit* can a moderator move this to the scripting section, i didnt notice it untill after i had made the inital post, and im not about to cross post and waste forum space. thanks.Code:[blackfox@21-130 etc]$ /usr/bin/perl SigX.pl Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.6/i386-linux /usr/lib/perl5/5.8.6 /usr/lib/perl5/site_perl/5.8.6/i386-linux /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.6/i386-linux /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl .) at SigX.pl line 22. BEGIN failed--compilation aborted at SigX.pl line 22. [blackfox@21-130 etc]$


Reply With Quote
