script to kill a pid giving error

Hi,

I simply want to kill a running process using a script that read pid from a file and tries to kill it .Getting error as shown below code..


cat $HOME/BackupScript.ksh.run | head -1 | while read pid
do
ps -p $pid > /dev/null 2>&1
if [$?=0]; then
kill -9 $pid
else
echo "no running $pid to kill" > /dev/null 2>&1
fi
done

kill_backup.ksh[12]: [1=0]:  not found.

Please suggest me how do I eliminate this error ..

if [ $? -eq 0 ]; then

Or you could use double equals signs (==).

Here is a useful if reference for Bash, should be good for other shells too.
Introduction to if

Please assist..

"Still same error message" isn't in any way helpful feedback.

What OS are you using? What shell? Post (using code tags) exactly how you modified the script, how you ran it, and the exact error message generated. What's the output of cat $HOME/BackupScript.ksh.run | head -1 ?

Also, your echo command is pointless. You've redirected stdout to /dev/null and then stderr to the same destination as stdout. It will never echo anything. Perhaps you meant to redirect echo's output to stderr? If so, drop all those redirections and simply use 1>&2 .

Regards,
Alister

Error is on line 12 (numbered from zero). There are not 13 lines in your script.
Please post the current version of the script and the current error message.