Please help on shell scripts execution

I have already posted the question. Because previous post has sinked so that I have to ask the question again. I created the script and chmod it as 755. The ksh shell is in bin. Now I typed ./script_name.ksh to execute the script in the directory of that script. The return message was: Ksh: ./script_name.ksh: Not found. What does this mean? I typed script name correctly. I am really confused by this. Anyone could give ma a hand? Thanks a lot.

Also, another question for execution permission: if a folder's permission show like: drwxr-sr-x, what is group's r-s, The user's rwx=7, other's r-x=5, I couldn't find what is group's r-s. Please advise. Thanks again.

Try with the the following in line 1 of your script :

#! /bin/ksh

Jean-Pierre.

Yes, #! /bin/ksh is on the top of the script.

Have you looked to see if there are hidden characters in your script name?
You could check by doing somthing like

#ls | cat -v

If you see odd stuff in your name then that could be why?

Make absolutely sure that the /bin/ksh or the /usr/bin/ksh file exists and that you are referring to the correct file in your script. This error is what is encountered when the interpreter is not found.

As for your question about the directory permissions, please go through the tutorials. Perderabo has written an excellent tutorial on file permissions.

Andrek and blowtorch:

Thanks so much for your advice. I followed to check script name and ksh files in /bin/ksh and in /usr/bin/ksh. ksh files exist in these directories and script name has no hidden characters. Then I tried to kick it off. It still told me 'Not found'. Why do I check ksh files existing? Do I need to register my script in these ksh files or something else? I am confused by this. Any idea?

Remove line 1 (#! ..) and execute your script like that :

ksh ./script_name.ksh

Jean-Pierre.

aigles:

Thanks for your advice. I removed #!/bin/ksh from the top of script, then executed script like: ksh ./script_name.ksh. The UNIX returned these message:

./script_name.ksh [6]: not found
./script_name.ksh [13]: not found
./script_name.ksh [22]: not found
./script_name.ksh [24]: not found
./script_name.ksh [25]: not found
./script_name.ksh [27]: Oracle_sid: is not an identifier.

So where is the problem?

Can you post the script? Atleast the first 15 or so lines? And also, post the output of 'ls -ld /usr/bin/ksh /bin/ksh /bin /usr/bin'.

Hi two things, first a really simple one but I just got caught my self....:slight_smile:

are you in "bin" or are you doing a "ls bin" this will show the contents of bin, thus making it look like your file is where you are currently attached...but not...
do a "pwd" to make sure before you run the script.

AND.... this could be it....
the group "r-s" means you have set the "setGROUP ID" meaning that the file will have group onwership when it runs...

Check this link for more detail
http://www.dartmouth.edu/~rc/help/faq/permissions.html

Can you post the ls -al out put for script and your "id" out put aswell...THANKS

Andrek,
The group r-s on a directory has a totally different meaning. It means that any files that are created in the directory, will be created with the group ownership that will be the same as that of the directory.

Go to the tutorials, and read through Perderabo's file permissions tutorial. Very well written.

blowtorch, Andrek:

Thanks so much for your help. I post whole script here for your review. Then I will come back to post other information by using 'ls -ld'.

#!/bin/ksh

# Created By: xxxxx
# Created On: 9/14/06
# Description: This script update xxx information for xxxx

# Check to make sure the correct number of parameters have been enetered.
#if [[ $# -lt 1 ]] then
# echo "Incorrect number of parameters."
# echo "Usage: $0 [ORACLE_SID]"
# exit 1
# fi

#Initialize variables.
ORACLE_SID=$1
ORACLE_HOME=/oracle/product/9.2.0
WORK_DIR=`dirname $0`
MINUTES=0
#FILECOUNT=0
#FILETRANSFERED=1
DBDOWN=1

# Change to working directory.
cd $WORK_DIR

# Set environment variables.
export ORACLE_SID
export ORACLE_HOME
export PATH=$PATH:/oracle/product/9.2.0:/oracle/product/9.2.0/bin

# Check to make sure that the database is available.
while [ $DBDOWN -eq 1 ]
do
sqlplus -s > /dev/null 2>&1 "dbuser/password@$ORACLE_SID" <<EOF
whenever sqlerror exit 1
select * from dual;
exit 0
EOF

if [ $? = 1 ]
then DBDOWN=1
date +"%D %T: Still waiting for $ORACLE_SID to become available." >> updt_attrib.log
sleep 60
else DBDOWN=0
fi
done

date +"%D %T: Database $ORACLE_SID is up and running." >> updt_attrib.log
echo "" >> updt_attrib.log

# Start SQL script to update xxxx table.

date +"%D %T: update attributes script started." >> updt_attrib.log
sqlplus -s > temp.log 2>&1 dbuser/passwd@oracle_sid @tools/updt_attrib.sql

if [ $? = 0 ]
then date +"%D %T: $scripts successfully executed." >> updt_attrib.log
else date +"%D %T: Error executing script." >> updt_attrib.log
grep "ORA-" temp.log >> updt_attrib.log
date +"%D %T: Exiting script." >> updt_attrib.log
mail -s 'DB Update: Unsuccessful. See Log file for errors.'
xxxx@company.com&lt;updt_attrib.log
exit 1
fi
done

date +"%D %T: End update attributes in xxx data warehouse." >> updt_attrib.log
mail -s 'End update attributes in xxx data warehouse.' xxxx@company.com&lt;updt_attrib.log
exit 0

Most of errors are on empty lines.
Verify that there is not non printable characters.
Execute the following command and show us the output please :

head -27 your_script | od -cx

Jean-Pierre.

aigles, blowtorch and Andrek:

Thanks for your patient and help. I have solved ptoblem. I think it was PATH environment variable. So I add:" PATH=$PATH:/bin: /usr/bin; export PATH" to the start of my script. Then add a line "echo "" >>log file". Then I executed script successfully. It call SQL script to update records in the target table.

So it was not empty line issue. But I do run "head -27 your_script | od -cx". the output was like this (too long, just post a part of it).

0000000 # ! / b i n / k s h \n P A T H =
2321 2f62 696e 2f6b 7368 0a50 4154 483d
0000020 $ P A T H : / b i n : / u s r /
2450 4154 483a 2f62 696e 3a2f 7573 722f
0000040 b i n ; e x p o r t P A T H
6269 6e3b 2065 7870 6f72 7420 5041 5448
0000060 \n # \n # C r e a t e d B y :
0a23 0a23 2043 7265 6174 6564 2042 793a
0000100 \t \t F r a n k L i \n # C r e
0909 4672 616e 6b20 4c69 0a23 2043 7265
0000120 a t e d O n : \t \t 9 / 1 4 / 0
6174 6564 204f 6e3a 0909 392f 3134 2f30
0000140 6 \n # D e s c r i p t i o n :
360a 2320 4465 7363 7269 7074 696f 6e3a
0000160 \t \t T h i s s c r i p t u p
0909 5468 6973 2073 6372 6970 7420 7570
0000200 d a t e C o n t r a c t o r
6461 7465 2043 6f6e 7472 6163 746f 7220
0000220 i n f o r m a t i o n f o r
696e 666f 726d 6174 696f 6e20 666f 7220

Anyway, you guys are genius in UNIX. I am so glad to learn from you.