I've been trying to run a script using chmod
.
Here's how I tried to execute the script:
$ chmod u+x tester
$ ./tester
./tester: Command not found.
I always get the Command not found error and I'm struggling to figure out why. Tried the full path fix too and run chmod
from there but still it won't solve the problem.
I used ls -l tester
and here's my access permission:
-rwxr-xr-x 1 kplus user123 983 Jan 28 15:00 tester
Here's the complete version of the Linux that I am using:
Linux KODRL58IRA02 2.6.18-308.e15 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64
Here's the script that I am trying to run:
#!/bin/ksh
echo ""
echo " = K+WA =";
WA_PORT="`cat /home/kptp4/testdirectory2/kondor.active |grep PORTAL_PORT|cut -d '&' -f 2`"
#== Checking Tomcat of WebAccess
printf "%25s" Tomcat
touch /home/kptp4/processiddirectory/tomcat-*.pid
PID=`cat /home/kptp4/processiddirectory/tomcat-*.pid`
if [[ $PID = "" ]];then
echo " x 0"
else
PSPID=`/bin/ps -eo pid | grep -w $PID`
if [[ $PSPID -eq $PID ]];then
/bin/ps -ef | grep $PID | grep -v grep | awk 'NR==1 {print " = "$8 $9 $10 $11 $12 $13 $14 $15}'
else
echo " x 0"
fi
fi
PORT_STATUS=`netstat -an | grep ${WA_PORT} | grep LISTEN | perl -pe "s/^.+\n/LISTENING/g;"`
PORT_STATUS=${PORT_STATUS:="NOT LISTENING!!!"}
echo " Port ${WA_PORT}/TCP = ${PORT_STATUS}"
cd /home/kptp4/WebAccessFolder
(PATH=/home/kptp4/testdirectory/checkall.sh;) | perl -pe "s,^, ,g;"
echo ""
I've also tried to run it using ksh
, bash
, sh
but no luck...
$ bash tester
: Permission denied
= K+WA =
: Permission denied
: Permission denied
tester: line 29: syntax error: unexpected end of file
$ sh tester
: Permission denied
= K+WA =
: Permission denied
: Permission denied
tester: line 29: syntax error: unexpected end of file
$ ksh tester
tester[2]: ^M: cannot execute [Permission denied]
= K+WA =
tester[4]: ^M: cannot execute [Permission denied]
tester[6]: ^M: cannot execute [Permission denied]
tester: line 10: syntax error at line 29: `if' unmatched
Right now I'm wondering why I cannot run this script as I am able to run other scripts using the permission commands I have used above(chmod u+x filename
). Any idea how I can solve this? This script is working fine in my SunOS version of Linux by the way, and I am wondering why it doesn't execute properly in this system.
Any help would be much appreciated, thank you!