Sponsored Content
Top Forums Shell Programming and Scripting To generate the FTP Script file Post 302180850 by konankir on Tuesday 1st of April 2008 10:56:59 AM
Old 04-01-2008
To generate the FTP Script file

Hi,

I am new to the shell programming.,

My requirement is , I have an shell file, which call internally the sql file, which generates 4 files on the directory., and then shell has to create the file which contains all the ftp commands to extract the files to different server for later processing.

Please have a look at the below script and please help me out in regards.,

#!/bin/ksh
################################################################################
INPARM=$1
. /sharedapps/etlusr/etlusrenv/etlusrenv repcommitments
#To remove the old log files
if [ "$INPARM" = staging ]; then
FTPLOGIN=$STGFTPLOGIN
FTPPASSWD=$STGFTPPASSWD
SERVERNAME=$STGSERVERNAME
FILEPREFIX=ORDPT.
ORAUSER=ecometlusr/ecometlusr_dev@ecomd

elif [ "$INPARM" = qa ]; then
FTPLOGIN=$QAFTPLOGIN
FTPPASSWD=$QAFTPPASSWD
SERVERNAME=$QASERVERNAME
FILEPREFIX=ORDPT.
elif [ "$INPARM" = production ]; then
FTPLOGIN=$PRODFTPLOGIN
FTPPASSWD=$PRODFTPPASSWD
SERVERNAME=$PRODSERVERNAME
FILEPREFIX=ORDPP.
else
echo "NOTE: $INPARM is not a valid running environment"
echo "Usage: rep_commitment_load.ksh <staging/qa/production>"
exit 1
fi
echo running line1
cd $LOGPATH
rm rep_commitment_load*
OUTPUTLOGFILE=$LOGPATH/rep_commitment_load.log;export OUTPUTLOGFILE;
FILEPATH="/sharedapps/etlusr/etl/ftp"
OLDDATAPATH="/sharedapps/etlusr/commitments/olddata"
OUTPUTLOGFILE=$LOGPATH/rep_commitment_load_ftp.log;export OUTPUTLOGFILE;
echo "OUTPUTLOGFILE $OUTPUTLOGFILE" >>$OUTPUTLOGFILE

cd $FILEPATH
temp=`ls ORD*`
for prevfile in $temp; do
mv $prevfile $OLDDATAPATH/$prevfile.`date +%d%h%m%s`
done

echo $prevfile >>$OUTPUTLOGFILE
echo "open $SERVERNAME">$LOGPATH/rep_commitment_load_ftp
echo "user $FTPLOGIN $FTPPASSWD">>$LOGPATH/rep_commitment_load_ftp
echo "quote site blocksize=8000 lrecl=80 recfm=fb">>$LOGPATH/rep_commitment_load_ftp
#echo "cd ..">>$LOGPATH/rep_commitment_load_ftp
echo "lcd $FILEPATH">>$LOGPATH/rep_commitment_load_ftp
sqlplus -s $ORAUSER <<EOF >OUTPUTLOGFILE
@$SCRIPTDIR/rep_commitment_load.sql
EOF
echo cd $FILEPATH
echo "mput ORD* >>$LOGPATH/rep_commitment_load_ftp
echo "close">>$LOGPATH/rep_commitment_load_ftp
echo "quit">>$LOGPATH/rep_commitment_load_ftp
echo "Done FTP commands"
cd $LOGPATH
ORAERRCNT=`cat rep_commitment_load* | grep "ORA-"|wc -l`
ONECNT=1
if [ $ORAERRCNT -lt $ONECNT ]; then
ftp -ivn < $LOGPATH/rep_commitment_load_ftp >$LOGPATH/rep_commitment_load_ftp.log

================================================================
Rep Commitment Load process successfull.
Please check log file - $OUTPUTLOGFILE
================================================================="
exit 0
else
cat $FILEPATH >> $OUTPUTLOGFILE
echo "
================================================================
Rep Commitment Load process failed with ORA errors.
Please check log file - $OUTPUTLOGFILE
================================================================="
exit 1
fi
exit 0
fi
exit;


Raja
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to generate html file using script?

Hi Friends I have an requirement that i need to generate html file using script. and the script output shold keep adding to that html file like tablewise. can anyone please help me out in this. thanks Krish. (2 Replies)
Discussion started by: kittusri9
2 Replies

2. UNIX for Dummies Questions & Answers

generate CSV file using AWK script

Hi guys I have a text report that consists of text in some parts and data in some parts. e.g Report for changes in cashflows No changes were found Report for changes in Bills deal_num deal_date trader maturity log_creator DF_234 20-5-2008 tman 20-5-2009 tman... (2 Replies)
Discussion started by: magikminox
2 Replies

3. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

4. Shell Programming and Scripting

Script to generate csv file

Hello; I need to generate a csv file that contains a list of all the files in a particular server (from the root directory ie: \) that have a permission stamp of 777. I would like to create the csv so that it contains the following: server name, file name, full path name where file exists,... (17 Replies)
Discussion started by: gvolpini
17 Replies

5. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

6. Shell Programming and Scripting

Shell script to compare and generate a new file

Requirement is I have two files their format is File1 - input_file ----- tmp_value|3|number|| tmp_value1|3|alpha|| tmp_value2|6|alpha|AA AA| tmp_value3|15|number|000000005| tmp_value4|15|number|000000000000000| tmp_value5|11|alpha|bbbbbbbbbbb| tmp_value6|11|alpha|bb bb| input_file ... (4 Replies)
Discussion started by: greenworld123
4 Replies

7. UNIX for Dummies Questions & Answers

Need script to generate file.

Hi I have a file "test" with data as below 1,APRIL,NEW,"New market,delhi,pune,India",RECENT, 254664 2,MARCH,OLD,"New Area,Mumbai,UP,India",CURRENT, 152483 So I want a script which provides output as below 1,APRIL,RECENT,254664 2,MARCH,CURRENT,152483 I am aware we can use awk/sed... (9 Replies)
Discussion started by: sv0081493
9 Replies

8. Shell Programming and Scripting

Script to generate csv file

Dears, I am new in shell world and I need your help in this, I have to create a report based on the output file generated by another program. I want to write a shell script for this. The output file generated every 15 minutes but i can’t open it until the end of day so the script will get the... (3 Replies)
Discussion started by: abdul2020
3 Replies

9. Shell Programming and Scripting

Script to generate .csv file

Dears,I need your help in this, I have to create a report based on the output file generated by another program. I want to write a shell script for this. The output file generated every 15 minutes but i can’t open it until the end of day so the script will get the file as an input the file will be... (8 Replies)
Discussion started by: abdul2020
8 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 02:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy