![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 12:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 12:06 AM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 07:15 AM |
| returning to the parent shell after invoking a script within a script | gurukottur | Shell Programming and Scripting | 5 | 09-26-2006 04:05 AM |
| return valuse from child script to parent script | borncrazy | Shell Programming and Scripting | 1 | 08-20-2004 12:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help with script
Hi,
I am completley new to Unix and shell scripts. I need to write a script that does the following: selects 2 values from a table on an oracle database (directory structure) ftps a .csv file from a Win server to a Unix server (directories from above sql) changes directory uses a utility called mload to upload data I know how to write the select statement but do I write it in my script or do I write a separate sql script that I call from my shell script? if so, how do I pass the values I retrieve from the database back to the calling shell script. I am also unclear on how to use ftp in my script to ftp the csv file. The rest I know how to do. If someone could give me some hints, point me in the right direction, or point me to some samples, I would greatly appreciate it. thanks, KKC |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |