#!/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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |