#1
  1. No Profile Picture
    d0g1e
    Guest
    Devshed Newbie (0 - 499 posts)
    I wrote a script to check the cpu usage of my rc5des cracker using the top command. i did it like this (this is a tiny part):

    $cpu_usage = `top -n1 | grep "rc5des"`;
    $cpu_usage =~ s/ / /g;
    print $cpu_usage;

    (with the content-type, <html> tags etc)
    but it doesn't display the content when i visit the script via a browser. It DOES display it when running the script from console. The rest of the script works fine, because when i replace the top command width uname -n, it displayed the correct server name. please help

    -- d0g1e
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>It DOES display it when running the script from console.

    Have you tried the full path to 'top' command like..
    $cpu_usage = `/usr/bin/top -n 1 | grep "rc5des"`;

    I do not know exactly what are you trying to do with this script, maybe the following script should help you in some ways..
    ############################################
    #!/usr/local/bin/perl
    print "Content-type: text/htmlnn";
    @top = `/usr/bin/top -n 1 | grep rc5des`;
    chop(@top);
    foreach $value (@top) {
    ($pid,$username,$pri,$nice,$size,$res,$state,$time,$wcpu,$cpu,$command) = split(/s+/,$value);
    print "$cpun";
    }
    exit;

IMN logo majestic logo threadwatch logo seochat tools logo