Here is the whole sarexec.pl for you.. #sarexec.pl code.....
#!/usr/bin/perl -w #exec /usr/bin/perl /research-sar/sarexec.pl use strict; #starting sar.... if($ARGV[0] eq 'start') { # Checking for correct parameters.. if (exists $ARGV[1] && exists $ARGV[2] && exists $ARGV[3]) { #print "present all things\n"; } else { #print "Missing parameters..cant continue..\n"; exit; } my $file_param; my $file_location; my $interval; $file_param = $ARGV[1]; $file_location = $ARGV[2]; open(FH,"> fileloc") or die"cant open the file"; print FH $file_location or die"cant print to file"; close(FH) or die "cant close the file"; $interval = $ARGV[3]; my $pid = fork(); if($pid==0) { #print "In child"; #print "$file_param"; my $param1; open FH,"< $file_param" or die"cant open the file"; #print "$file_param"; $param1 = <FH>; close FH or die "cant close the file"; chomp($param1); #print $param1; #my $testvar="-wWbB"; system("sar -o logfile $param1 $interval 0 > /dev/null&"); exit 0; } else { #print "In parent"; my $exitstatus = wait(); exit; } } # stopping sar..... elsif($ARGV[0] eq 'stop') { # Checking for correct parameters.. if (exists $ARGV[1]) { print "Bad parameters cant process\n"; exit; } my $loc; open FH, "< fileloc" or die " cant open file"; $loc = <FH> ; #print $loc; chomp($loc); close FH or die "cant close file"; system("kill \$(pidof sadc)"); system("sar -f logfile>>$loc"); } else { print " Wrong parameters"; }

In reply to Re^2: Running Perl scripts from ssh by agaream
in thread Running Perl scripts from ssh by agaream

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.