Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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
    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&#58; $MYUPTIME *<*";
    $DATA_2_SEND .= "CPU&#58; $CPUNAME *<*";
    $DATA_2_SEND .= "MHZ&#58; $CPUSPEED *<*";
    # $DATA_2_SEND .= "BOGOMIPS&#58; $BOGOMIPS *<*";
    $DATA_2_SEND .= "OS&#58; $UNAME *<*$MEMPERCENT% Ram Used | Total RAM = $MEMTOTAL | $
    $DATA_2_SEND .= "Diskspace&#58; $HDD Free&#58; $HDDFREE *<*";
    # $DATA_2_SEND .= "Screen Res&#58; $RES";
    $DATA_2_SEND .= "Currently Listening to&#58; $XMMSSONG at $XMMSPOSITION/$XMMSTIME.";
    #print $DATA_2_SEND;
    
    
    
    
    
    my %form = &#40;&#41;;
    
    %form =&#40;'username' => $username,
    	'password' => $password,
    	'data'	   => $DATA_2_SEND,
    	'Submit'   => ''&#41;;
    
    my $ua = new LWP&#58;&#58;UserAgent;
    my $curl = url&#40;"http&#58;"&#41;;  
    my $req = new HTTP&#58;&#58;Request 'POST','http&#58;//sigx.yuriy.net/update.php';
    $req->content_type&#40;'application/x-www-form-urlencoded'&#41;;
    $req->content&#40;$curl->equery&#41;;
    $curl->query_form&#40;%form&#41;;
    $req->content&#40;$curl->equery&#41;;
    my $response= $ua->request&#40;$req&#41;->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:
    &#91;blackfox@21-130 etc&#93;$ sh SigX.pl
    SigX.pl&#58; line 20&#58; $&#58; command not found
    SigX.pl&#58; line 20&#58; =1&#58; command not found
    SigX.pl&#58; line 22&#58; use&#58; command not found
    SigX.pl&#58; line 23&#58; use&#58; command not found
    SigX.pl&#58; line 24&#58; use&#58; command not found
    SigX.pl&#58; line 27&#58; my&#58; command not found
    SigX.pl&#58; line 28&#58; my&#58; command not found
    SigX.pl&#58; line 29&#58; my&#58; command not found
    SigX.pl&#58; line 31&#58; =&#58; command not found
    SigX.pl&#58; line 33&#58; =AMD&#58; command not found
    SigX.pl&#58; line 34&#58; syntax error near unexpected token `=$CPUNAME=~/^\s*'
    SigX.pl&#58; line 34&#58; `&#40;$CPUNAME&#41;=$CPUNAME=~/^\s*&#40;.*?&#41;\s*$/;  # trim head/tail at same time'
    &#91;blackfox@21-130 etc&#93;$

  2. #2
    Linux Engineer
    Join Date
    Apr 2005
    Location
    Buenos Aires, Argentina
    Posts
    908
    Well, you will have to fix that script first..

    Also:
    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
    Did you know that you can simplify that to..
    */2 * * * * /etc/SigX.pl >/dev/null 2>&1
    serzsite.com.ar
    "All the drugs in this world won\'t save you from yourself"

  3. #3
    Just 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...

  4. $spacer_open
    $spacer_close
  5. #4
    Linux 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"

  6. #5
    Just 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.
    Code:
    &#91;blackfox@21-130 etc&#93;$ /usr/bin/perl SigX.pl
    Can't locate CGI.pm in @INC &#40;@INC contains&#58; /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 .&#41; at SigX.pl line 22.
    BEGIN failed--compilation aborted at SigX.pl line 22.
    &#91;blackfox@21-130 etc&#93;$
    *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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •