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
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 just wondering if i did the right thing, if not someone correct me. this isnt as easy as it was in windows lol.
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.
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;
so thats it, im just looking for a little help, hopefully someone here has already done this and knows how to. thanks guys.
**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]$