Anthony, system() return the exit status. Type "perldoc -f system" . When the command is successful, you will get 0. --- [EMAIL PROTECTED] wrote: > As a test I would print $mypid and it had the > correct pid number in it. > > Here is the complete script, if it will help... > > #!/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"); > chop($mypid); > print "Killing instance..."; > #print "$mypid"; > print $mypid; > #system("kill $mypid"); > } > exit; > > sub wanted { > my $entry = "$File::Find::name" if -e; > 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 PROTECTED] > Subject: Re: Problem with variable in system command > > > > $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 not being > > read correctly. I run the script and the kill > > process tries to run > > without the variable. Here is a post of the code > I > > have. Anyhelp > > would be greatly appreciated. > > > > > > find(\&wanted,$dir); > > > > foreach my $afile (@dirstruct) { > > $mypid = system("cat $afile"); > > chop($mypid); > > print "Killing instance..."; > > system("kill $mypid"); > > > > > > I wrote this script a few weeks ago and it worked > > great, but I accidentally > > deleted it and can't rememeber exactly how it was > > written. :-/ > > > > > > -- > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > __________________________________________________ > Do You Yahoo!? > Everything you'll ever need on one web page > from News and Sport to Email and Music Charts > http://uk.my.yahoo.com > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] >
__________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]