|
Hi,
this script (Korn shell) targets these 2 problems:
# [BEGIN script] -----------------------------------------
# 1. Extract the data from the DB
typeset DB_VALUEs=$(sqlplus -s YOUR_USER_NAME/YOUR_USER_PASSWORD@YOUR_DB_NAME <<ENDSQL
set echo off
set lines 120 pages 120 feedback off
SET HEADING OFF
select YOUR_COLUMNs from YOUR_TABLE;
ENDSQL
)
# Remove newline characters
DB_VALUEs=$(echo ${DB_VALUEs})
#echo "DB_VALUEs = '${DB_VALUEs}'"
# 2. FTP a single file
# Create a temporary file for the FTP dialog
typeset TMP_FILE=$(mktemp); RC=$?
if [[ ${RC} -ne 0 ]]; then
echo "ERROR: cannot create a temporary file... (RC=${RC})"
exit ${RC}
fi
# Create a temporary file for the FTP output
typeset OUT_FILE=$(mktemp); RC=$?
if [[ ${RC} -ne 0 ]]; then
echo "ERROR: cannot create a temporary file... (RC=${RC})"
exit ${RC}
fi
# Run the FTP command ()
cat >${TMP_FILE} <<!
open YOUR_FTP_SERVER_NAME
user YOUR_FTP_USER_NAME YOUR_FTP_USER_PASSWORD
binary
lcd YOUR_LOCAL_FILE_DIRECTORY
put YOUR_FILE_NAME
close
!
ftp -n <${TMP_FILE} > ${OUT_FILE}
echo "RESULT code: '$?'"
rm ${TMP_FILE}
echo "RESULTs:"
cat ${OUT_FILE}
rm ${OUT_FILE}
# [END script] -------------------------------------------
where the 'YOUR_xxx' strings should be customized.
Please tell me if it works and if it fits your needs.
C.
|