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
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
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
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
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
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
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
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
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
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
print(1) User Commands print(1)
NAME
print - shell built-in function to output characters to the screen or window
SYNOPSIS
ksh
print [ -Rnprsu [n]] [arg...]
DESCRIPTION
ksh
The shell output mechanism. With no flags or with flag - or -, the arguments are printed on standard output as described by echo(1).
OPTIONS
The following options are supported:
-n suppresses new-line from being added to the output.
-R
-r (raw mode) ignore the escape conventions of echo. The -R option will print all subsequent arguments and options other than
-n.
-p causes the arguments to be written onto the pipe of the process spawned with |& instead of standard output.
-s causes the arguments to be written onto the history file instead of standard output.
-u [ n ] flag can be used to specify a one digit file descriptor unit number n on which the output will be placed. The default is 1.
EXIT STATUS
The following exit values are returned:
0 Successful operation.
>0 Output file is not open for writing.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
echo(1), ksh(1), attributes(5)
SunOS 5.10 15 Apr 1994 print(1)