Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it

This is how we execute the script (and this is the requirement)
------------------------------------
bash-2.05$ processkill
Usage: ./processkill [-p|-f] [-u username] [num] regex
Kill processes matching a regular expression
-p: print processes matching regular-expression, don't kill
-f: force (don't ask)
num: send specified number to process. 15 if none given
bash-2.05$
bash-2.05$
bash-2.05$
bash-2.05$ processkill -u <username> 9 <process_name>
3937 /app/share/java/1.4.2_08/bin/java -Djava.library.path=/app/shar
5269 /app/share/java/1.4.2_11/bin/java -Xms128m -Xmx256m -Djava.library.path
55824 /app/share/java/1.4.2_11/bin/java -Xms128m -Xmx256m -Djava.library.path
349187 /app/share/java/1.4.2_08/bin/java -classpath /app/share/config:
Kill these processes? (y|n)n
No processes killed

If Yes, it kill all the above mentioned process
------------------------------------

But now we are getting this error part when we try to execute the script
-------------------------------------

./killproc: line 9: my: command not found
./killproc: line 10: my: command not found
./killproc: line 11: my: command not found
./killproc: line 12: my: command not found
./killproc: line 14: syntax error near unexpected token `{'
./killproc: line 14: `if($#ARGV==-1 || $ARGV[0]=~/-h/){'
------------------------------------

This is the Script.
-----------------------------------

#!/usr/bin/perl -w
#
# Kill processes matching a regular expression

# TODO:
# -Use perl function to access process managment instead of @ps=`ps ...`

my $force=0;
my $print_only=0;
my $user_name="";
my $regex;

if($#ARGV==-1 || $ARGV[0]=~/-h/){
print "Usage: $0 [-p|-f] [-u username] [num] regex\n" .
" Kill processes matching a regular expression\n" .
" -p: print processes matching regular-expression, don't kill\n" .
" -f: force (don't ask)\n" .
" num: send specified number to process. 15 if none given\n";
exit;
}

if($ARGV[0]=~/^-p/){
$print_only=1;
shift(@ARGV);
}
elsif($ARGV[0]=~/^-f/){
$force=1;
shift(@ARGV);
}

if($ARGV[0]=~/^-u/){
shift(@ARGV);
$user_name = shift(@ARGV);
# print"*** $user_name\n\n";
}

$signal=15;

if($ARGV[0]=~/^\d*$/){
$signal=$ARGV[0];
shift(@ARGV);
}

$regex=$ARGV[0];

#@ps=`ps --no-header -Ao pid,args`;
if ($user_name)
{
@ps=`ps -u $user_name -o pid,args`;
}
else
{
@ps=`ps -Ao pid,args`;
}

$kill_apps="kill -$signal ";
$num2kill=0;
shift @ps;
foreach $ps (@ps){
$ps =~ /^\s*(\d*)\s*(.*)$/;
$pid=$1; # process-ID
$command=$2;
if($command=~/$regex/ && $$!=$pid){
if($print_only or !$force){
print "$pid $command\n";
}
$kill_apps.="$pid ";
$num2kill++;
}
}

if(!$print_only && $num2kill!=0){
$answer="y";
if($force==0){
print "Kill these processes? (y|n)";
$answer=<STDIN>;
}
if($answer=~/^y/ or $answer=~/^Y/){
print $kill_apps;
print `$kill_apps 2>&1`;
print "\n";
}
else{
print "No processes killed\n";
}
}

-----------------------------------

Is there any basic thing we are missing? could any one help us

Regards
jonnyvic

hello buddy,
I parsed your code and practically everything seemed to be correct.
I feel you there is something wrong with the interpreter line.
check the path of your perl binary aka #which perl
so the first line should be
#!<the_actual_path_that_is_returned_by_which perl>
probably in your earlier env you would have been having this path
/usr/bin/perl
but perl is installed in some other dir.
correct the first (interpreter line ) as stated above and your code will run fine.
Hope you get it working.
ttyl

Thank for the info buddy, the path is wrong.. i chnaged the path it started working fine...

thanks again