Thanks for your suggestions Ken

I've included the script below for perusal, it basically kills any 
apps which are open at the time of invokation - I got fed up doing it 
manually and didn't want to write an Applescript to do it. It works 
as expected when run from the command line using 'perl  script.pl', 
but fails silently when I try to call it by name, even after forcing 
OSX to place it in  "/usr/bin/"


At 11:11 AM -0500 19/07/01, Ken Williams wrote:

>I'm not sure what '/users/' means.  The syntax should be:
>   chmod ug+x some_file.pl

I had to put the full path name to the file for chmod to find it , I 
had it sitting on the desktop so the path was 
"/users/robinmcf/Desktop/"


>If there are spaces in the filename, you need quotes (single or 
>double):  chmod ug+x "some file.pl"

this issue I was aware of - there was a space in the name but I 
changed it to an underline (got fed up typing quotes)


>Another problem might be that the first line of the file needs to be 
>#!/usr/bin/perl
>............If that's wrong, the error is "Command not found".

the problem is I don't get any errors, at least none that I see in 
the console log - am I looking in the right place?

>Finally,............type the command 'rehash'.
I tried this but to no avail - the  file permissions are currently set at:

-rwxr-xr-x  1 robinmcf  staff       788 Jul 20 02:08 App_reaper.pl

the path is:

/usr/bin/App_reaper.pl

and the script looks like this:


#!/usr/bin/perl -w

#=========== declare includes =============

use strict;
use diagnostics-verbose;

#========== declare variables =============

my(@temp,$path,$app,$pid,$temp,@keys,%reaper);

#============= script body ================


# to get the process numbers of applications running
# we open a pipe to read from

open (PID, "ps -x |") || die "unable to, OS says $!";

# then we filter the ouput to make sure we don't have any system processes
# mixed in with the apps we want to kill

while (<PID>){

        next unless (/\/Applications/);
        @temp= split/\//,$_;
        ($temp,$pid)= split(/\s+/, shift(@temp));
        ($app,$temp)= split(/\s/, pop(@temp));
        $path= join('/',@temp);

        # I don't want to kill the terminal or I won't see the 
script's return value
        $reaper{$pid}="$path/$app" unless ($app=~/T/);

}


@keys = keys(%reaper);
$temp=kill 1,@keys;
print "$temp\n";

Reply via email to