The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to generate html file using script? kittusri9 Shell Programming and Scripting 2 05-25-2008 11:38 PM
Script to generate text file from excel file isingh786 UNIX for Dummies Questions & Answers 1 01-24-2008 10:32 AM
generate xml from a shell script speedieB UNIX for Dummies Questions & Answers 1 07-27-2006 08:38 AM
Modify script to generate a log file heprox Shell Programming and Scripting 2 06-14-2006 10:40 AM
ksh Script to Generate Symbolic Links dwisconbug Shell Programming and Scripting 1 05-08-2006 07:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-01-2008
konankir konankir is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
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
  #2 (permalink)  
Old 04-01-2008
unilover unilover is offline
Registered User
  
 

Join Date: Mar 2008
Location: Toronto, Canada
Posts: 66
If you want clear help, you have to present clear problem-definition!!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0