Starting a script from a Database procedure

Hey guys,

I have this problem : I can run on an sqlprompt

!ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous

which will ftp the file from Unix to an NT machine, but if I do

exec shell('sh ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous') it does NOTHING.

I have no .netrc file in my home directory and don't know how to build it, but I even don't know if this file is necessary for me ?

Can u please help ??????:confused:

I've used this package and daemon process to execute system commands from the database, it worked for what I wanted. it may be worth lookin at. I needed to execute a shell script after some sql was triggered

hth

http://www.greatchinatelecom.com/card/oracle/14082.html

Thx edog !

But the problem is that it took already one month to let dba's and unix people set up the method with the shell procedure and next week we'll go in production already so I can't use your option (But I will definitely use it in a next project) !

:cool:

by the way, here 's the code from the script I start

###############################################################################
# --------------
# Parm's control
# --------------
INPUTFILE=test.xml
DESTINATION=172.16.204.81
USERID=Anonymous
PASSWD=Anonymous
DIRECTORY=""
CHANGE_DIR='No'
# ---------------
# Execute the FTP
# ---------------
if [[ "$CHANGE_DIR" = "No" ]] ; then
ftp -n ${DESTINATION} >templog1$$ >>templog2$$ << EOF
user ${USERID} ${PASSWD} account
put ${INPUTFILE}
EOF
RCOD=$?
# ---
else
# ---
ftp -n ${DESTINATION} >templog1$$ >>templog2$$ << EOF
user ${USERID} ${PASSWD} account
cd ${DIRECTORY}
put ${INPUTFILE}
EOF
RCOD=$?
fi
# --> Save return code
RCOD=$?
# --> Remove logs file (to comment for debug)
rm templog1$$ templog2$$
# --> check FTP run
if [ $RCOD -ne 0 ] ; then
echo "ERROR: Load of file $INPUTFILE crash with error $RCOD"
exit 2
fi
# ---------------------
# Now it's time to exit
# ---------------------
exit $RCOD

exec shell('sh ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous') it does NOTHING.

what does your sql procedure, 'shell' look like? I assume its a custom procedure, maybe if you enter the full path of the ksh script, but I'd need to see the procedure venture any other guesses.

when you execute it from sqlplus your .profile probably has the path to ftp_file2.ksh or you were in that directory when you started sqklplus, but from a sql procedure there is no profile to find the script? just a thought

(sorry for the delay - just passed the weekend) :slight_smile:

The shell procedure :

procedure shell (cmd IN CHAR)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);

This is just the standard one provided by Oracle.

That from the .profile is right i gess because
!ftp_file.ksh is executed on the unix prompt
while
exec shell('...'); goes through the Listener.

I did send the system people the procedure to setup the listener - maybe they just have forgotten. Anyway, i did send them a mail about that.