Please help on shell scripts execution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help on shell scripts execution
# 8  
Old 09-19-2006
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?
# 9  
Old 09-19-2006
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'.
# 10  
Old 09-19-2006
Hi two things, first a really simple one but I just got caught my self....:-)

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
# 11  
Old 09-20-2006
Quote:
Originally Posted by Andrek
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...
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.
# 12  
Old 09-20-2006
Quote:
Originally Posted by blowtorch
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'.
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<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<updt_attrib.log
exit 0
# 13  
Old 09-20-2006
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 :
Code:
head -27 your_script | od -cx

Jean-Pierre.
# 14  
Old 09-20-2006
Quote:
Originally Posted by aigles
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 :
Code:
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.

Last edited by duke0001; 09-21-2006 at 11:03 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check sub scripts execution?

I have a shell script which is used to get the input and have another shell script (a sub script) at the end of this shell script which is used to upload the inputs in the Oracle database. I can check the execution status of the parent script using sh -x script.sh. but this command doesn't show the... (1 Reply)
Discussion started by: srilaxman
1 Replies

2. UNIX for Dummies Questions & Answers

Execution problem in running multiple scripts

hi all, I have 3 individual scripts to perform the task . 2nd script should run only after the 1st script and 3rd script must run only after first 2 scripts are executed successfully. i want to have a single script that calls all this 3 scripts .this single script should execute the 2nd script... (1 Reply)
Discussion started by: Rahul619
1 Replies

3. Shell Programming and Scripting

Shell execution

hi, Pls bare with me if this is trivial. Is it possible to run a korn shell with out specifying the name with its extensiion? Do i need to make any changes to the script make it work? Thanks (3 Replies)
Discussion started by: dvah
3 Replies

4. Shell Programming and Scripting

Execution difference in perl scripts for windows / AIX

Hi, I have perl script abc.pl which runs perfectly fine on windows ( execution from cmd). Now i tried to execute the same perl module on the AIX server after defining the captureoutput.pm and other relevant changes. But its behaving very weirdly as a portion of the URL which is formed by... (3 Replies)
Discussion started by: slayer0611
3 Replies

5. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

6. Shell Programming and Scripting

Questions on shell execution

Hi, I have a question regarding Korn shell script execution in HP-UX 11.11. What sort of environmental settings do I need to run a Korn shell script such as below without entering "./" at the begining of the command? cat test.ksh date I am able to do this with a user called infodba who... (6 Replies)
Discussion started by: stevefox
6 Replies

7. Shell Programming and Scripting

Scripts fails if you change its code during the execution.

So a script is working properly (tested many times) , then you add a new fine piece of code ,finaly its fails generally with a syntax error at the last line of the script. :confused:... does anybody why this happens? >uname -a HP-UX test... (4 Replies)
Discussion started by: Klashxx
4 Replies

8. UNIX for Dummies Questions & Answers

Scripts execution

hello everybody: i think this is really quite of dummy question. after I write a new script, and give it the execute permission. some times its just enough to call its name to run the script , other times I need to include ksh or ./ScriptName . so how I can make all my scripts run by just... (9 Replies)
Discussion started by: aladdin
9 Replies

9. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

10. Shell Programming and Scripting

execution of shell script

How can I execute another shell script from one? Malay (5 Replies)
Discussion started by: malaymaru
5 Replies
Login or Register to Ask a Question