I've written a script to search for all *.pid files in a dir, then do
a cat on the file. The script will then use this variable to kill the
process. The problem I'm having is that the varibale is not being
read correctly. I run the script and the kill process tries to run
without the variable.
$mypid contains the status of the process not its pid.
--- [EMAIL PROTECTED] wrote: > I've
written a script to search for all *.pid files
> in a dir, then do
> a cat on the file. The script will then use this
> variable to kill the
> process. The problem I'm having is that the
> varibale is no
and (substr
$entry, 0, -4))); #This will only work with *.pid
}
> -Original Message-
> From: Kernan, Anthony (GOT)
> Sent: Thursday, October 10, 2002 7:40 AM
> To: '[EMAIL PROTECTED]'
> Subject: Problem with variable in system command
>
> I'
;
push @dirstruct, $entry if (($entry ne '') && (( m/$ext$/) and (substr
$entry, 0, -4))); #This will only work with *.pid
}
-Original Message-
From: Dharmender Rai [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 8:06 AM
To: [EMAIL PROTECTED]; [EMAIL PROT
gt; push @dirstruct, $entry if (($entry ne '') && ((
> m/$ext$/) and (substr
> $entry, 0, -4))); #This will only work with *.pid
> }
>
>
>
> -Original Message-
> From: Dharmender Rai
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October
al Message-
From: Dharmender Rai [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 8:40 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: Problem with variable in system command
Anthony,
system() return the exit status. Type "perldoc -f
system" .
$mypid or die "Can't signal $mypid";
where $sig is whatever signal you want to send.
perldoc -f kill
>
> -Original Message-
> From: Dharmender Rai [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 10, 2002 8:40 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Problem with variable in system command
> Thanks for your replies. I understand that system() returns an exit
> code when it is done. My problem is that the command to be run by
> system() is not getting the variable
D]
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: Problem with variable in system command
>
>
> Thanks, it's working now. I couldn't get the perl kill to
> work, it kept
> dieing. I used system("
Anthony Kernan wrote:
>
> Here is the complete script...
>
> #!/usr/bin/perl -w
> use strict;
> use File::Find;
> my $dir = '/usr/local/etc/mrtg';
> my $ext = '.pid';
> my (@dirstruct);
> my $mypid;
>
> find(\&wanted,$dir);
>
> foreach my $afile (@dirstruct) {
> $mypid = system("cat $afile
10 matches
Mail list logo