Execution of shell script returns error 127


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution of shell script returns error 127
# 1  
Old 08-18-2011
Execution of shell script returns error 127

Hi All,

While running shell script i got following output.

interpreter "usr/bin/ksh" not found
sh: step1.sh: not found.
ldnhpux | oracle >echo $?
127
  • - Running command "which ksh" retruns
  • "usr/bin/ksh".
  • - I found some information on web stating to remove extra carriage return chars, To achieve that I tried using cat and sed commands. Did not work though.
  • - I tried ftp the file in ASC mode. No luck.

Any ideas ?Smilie

Regards
# 2  
Old 08-18-2011
Can you post
1. Permission given to the script
2. How did you execute the script in command line. (./scriptname or sh scriptname etc)
3. Contents of the script.
# 3  
Old 08-18-2011
Code:
1. -rwxrwxrwx   1 oracle     oinstall      3318 Aug 17 19:00 step1.sh

2. >step1.sh <parameters>

3. ======================================================
#!usr/bin/ksh
#set -x
################################################################################
# Script to extract Package Body, Function and Procedure source from Database and to create ORA file for each object.
# 
#################################################################################

# Set the variables to be used

# Specify the location where the wrap folder is created
wrappath=/acc/NATDUB11/wrapping
binPath=/usr/bin
logDir=${wrappath}/logs
objectDir=${wrappath}/objects
utilityDir=${wrappath}/utility
plbDir=${wrappath}/plb
listSQLFile=${utilityDir}/listFCUBS.sql
extractSQLFile=${utilityDir}/extractFCUBS.sql

listFile=${logDir}/filelistFCUBS.txt
extractlogFile=${logDir}/extractFCUBS.log

${binPath}/rm -f ${listFile} ${extractlogFile}
echo "Existing files removal done" >>${extractlogFile}

echo "##################STEP1 starts for ${2}##################"
echo "##################STEP1 starts for ${2}##################" >>${extractlogFile}

echo "Variables set"  >>${extractlogFile}

# Set Oracle Home
ORACLE_HOME=/ora9i/app/oracle/product/9.2.0.1.0
export ORACLE_HOME
errVal=1
successVal=0

# Preliminary checks
if [ $# -ne 2 ]
then
    ${binPath}/echo "Error: Incorrect Number of Parameters" >&2
    ${binPath}/echo "USAGE: $0 <dbusername>/<dbpassword>@<db schemaname> < dbusername >" >&2
    echo "Error: Incorrect Number of Parameters" >>${extractlogFile}
    exit ${errVal}
fi

if test ! -s ${listSQLFile} 
then
    ${binPath}/echo "Error: Cannot find List SQL file - ${listSQLFile}" >&2
    echo "Error: Cannot find List SQL file - ${listSQLFile}" >>${extractlogFile}
    exit ${errVal}
fi

if test ! -s ${extractSQLFile}
then
    ${binPath}/echo "Error: Cannot find Extract SQL file - ${extractSQLFile}" >&2
    echo "Error: Cannot find Extract SQL file - ${extractSQLFile}" >>${extractlogFile}
    exit ${errVal}
fi

echo "Preliminary checks done"
echo "Preliminary checks done" >>${extractlogFile}

# Fetch the list of objects
${ORACLE_HOME}/bin/sqlplus -l -s ${1} @${listSQLFile} ${2}>${listFile};<<EOF
exit;
EOF

echo "Fetched object names and type details, ${listFile} created"
echo "Fetched object names and type details, ${listFile} created" >>${extractlogFile}


# Fetch the object source and create the respective file for each object
echo "Extracting sources..."
while read inputlistfile
do
    ObjectName="$(${binPath}/echo $inputlistfile | ${binPath}/cut -f1 -d',')"
    ObjectType="$(${binPath}/echo $inputlistfile | ${binPath}/cut -f2 -d',')"
    #echo ${ObjectName} '~~~' ${ObjectType}
    echo "Extacting source for ${ObjectName} ${ObjectType}">>${extractlogFile}
    ${ORACLE_HOME}/bin/sqlplus -l -s ${1} @${extractSQLFile} ${2} ${ObjectName} "${ObjectType}">>${extractlogFile};
    #exit;
done <${listFile}
echo "Source extraction done"
echo "Source extraction of the objects done into ${objectDir} as LST files" >>${extractlogFile}

# Rename the lst file as ora file in the objects directory
cd ${objectDir}
for f in *.lst ; 
do
    mv $f `basename $f lst`ora; 
done

echo "ORA Files created in " ${objectDir}
echo "Files renamed as ORA files in "${objectDir} >>${extractlogFile}

cd ${utilityDir}

echo "Extraction Done"
echo "Extraction Done" >>${extractlogFile}

echo "##################STEP1 ends for ${2}##################"
echo "##################STEP1 ends for ${2}##################" >>${extractlogFile}
======================================================

Thanks


# 4  
Old 08-18-2011
Can you try executing the script as ./step1.sh <parameters> from the command line.. ?
# 5  
Old 08-18-2011
Same Error.
# 6  
Old 08-18-2011
Ok. Try as sh step1.sh <parameters> If you still get the same error then IMO you would need to include your script's path/location in the PATH variable. Or did you copy the file from windows to unix box..? Post few lines of output from cat -v filename. If you find control characters in the output then that should be the issue. Removing the control chars would resolve.
This User Gave Thanks to michaelrozar17 For This Post:
# 7  
Old 08-18-2011
Awesome, Its Running now. Hope it will finishes successfully.
Can you please tell me what difference does it make if we use sh ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies

2. UNIX for Dummies Questions & Answers

Shell script execution methods

Hi, Shell script can be executed in few ways. I would like to know the differences in the below execution methods. sh file1.sh . file1.sh . /file1.sh Please help, thank you. (2 Replies)
Discussion started by: Dev_Dev
2 Replies

3. UNIX for Advanced & Expert Users

SSH using shell script terminates the script execution

Hello, I am writing a shell script in which i do ssh to remote server and count the number of files there and then exit. After the exit the shell script terminates which i believe is expected behavior. Can some one suggest me a way where even after the exit the script execution resumes. ... (2 Replies)
Discussion started by: manaankit
2 Replies

4. Shell Programming and Scripting

Execution problem with shell script

Hi all, I want to use perl string manipulation commands in my shell script. I have written following script. echo "enter name" read name perl -e '$m=length($name); echo $m it gives an error: unrecognized token in perl command line. do not suggest me an equivalent command of shell... (3 Replies)
Discussion started by: admc123
3 Replies

5. Shell Programming and Scripting

execution of aliases from shell script

Hi I have to execute the commands in .aliases file from a shell script I tried 1.giving the alias directly in shell script 2.Giving the actually "value of alias" in the shell script 3. I tried giving both steps 1 and 2 inside ` quotes Still nothing is working . It says command... (3 Replies)
Discussion started by: ssuresh1999
3 Replies

6. Shell Programming and Scripting

Cron execution of shell script

Hi Guys, Unable to run this script from the cron,although the same executes perfectly from the command line.Please help. #!/bin/sh #### aprintd alarm creation files ##### file=`date +%m%d%Y` pid=$$ echo "$pid" /u01/app/netboss/bin/aprintd/aprintd > $file & childpid=$!... (3 Replies)
Discussion started by: ashish.sharma
3 Replies

7. Shell Programming and Scripting

problem with shell script execution

Hi All, i am running a shell script in which there is a command `ps -ef | grep smon > db` When i execute this command in the command prompt i am getting the desired output..but when the script is executed..the db file is getting created but with no values...I could not find the reason for... (2 Replies)
Discussion started by: anju
2 Replies

8. UNIX for Dummies Questions & Answers

Sequential execution in shell script?

I've a shell script that invokes a URL of an application to do some work, e.g., http://www.abc.com/myservlet?action=helloworld.Does the shell wait for a return value from the URL call before proceeding to the next line of command? (6 Replies)
Discussion started by: chengwei
6 Replies

9. 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

10. UNIX for Advanced & Expert Users

Serverhost 127.0.0 error message on apache

my apache 2.0 is up and running but after trying to reconfigure it for specifics I ended up with a permanent eror message that I can't seem to get rid of .. when I run the server ( just / */apachect1 start ) the message reads "cannot locate name localhost for server 127.0.0" so far I have tried... (2 Replies)
Discussion started by: moxxx68
2 Replies
Login or Register to Ask a Question