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
bdf script not working !! kpatel786 Shell Programming and Scripting 3 11-16-2007 11:10 AM
Pls. Help my script not working as it should cocoabeauty1 Shell Programming and Scripting 1 07-28-2007 05:11 PM
FTP script not working rookie250 Shell Programming and Scripting 2 12-19-2006 02:49 AM
Script not working as desired mhssatya Shell Programming and Scripting 39 08-23-2006 09:51 AM
Backspace Not Working in Script Atama Shell Programming and Scripting 4 04-26-2002 10:17 AM

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

Join Date: Mar 2008
Posts: 9
why the below script is not working .,

why the below script is not working .,

Can any one please help me out.,

for prevfile in $temp; do
prevfile=$prevfile.`date +%D%H%M%S`
mv $prevfile ../../commitments/olddata
done


Raja
  #2 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
What's the purpose of the for loop? Is $temp a wildcard or something?

How is it not working?
  #3 (permalink)  
Old 03-27-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,512
Quote:
Originally Posted by konankir View Post
why the below script is not working .,

Can any one please help me out.,

for prevfile in $temp; do
prevfile=$prevfile.`date +%D%H%M%S`
mv $prevfile ../../commitments/olddata
done


Raja
that's because you did not create the new file first before mv'ing to destination.
  #4 (permalink)  
Old 03-27-2008
konankir konankir is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
My actual Script is :

My actual Script is :

#!/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: gasbuster_incentive_extract.ksh <staging/qa/production>"
exit 1
fi
cd $LOGPATH
rm rep_commitment_load*
OUTPUTLOGFILE=$LOGPATH/rep_commitment_load.log;export OUTPUTLOGFILE;
cd /sharedapps/etlusr/etl/ftp/
temp=`ls ORD*`
for prevfile in $temp; do
prevfile=$prevfile.`date +%D%H%M%S`
mv $prevfile $OLDDATAPATH
done

#$prevfile=`find /sharedapps/etlusr/etl/ftp/ORD*`
echo $prevfile >>$OUTPUTLOGFILE
#mv `find /sharedapps/etlusr/etl/ftp/ORD*` $OLDDATAPATH/`find /sharedapps/etlusr/etl/ftp/ORD*`.`date +%D%H%M%S`
#echo "open $SERVERNAME">$LOGPATH/rep_commitment_load
echo "user $FTPLOGIN $FTPPASSWD">>$LOGPATH/rep_commitment_load
echo "quote site blocksize=8000 lrecl=80 recfm=fb">>$LOGPATH/rep_commitment_load
echo "cd ..">>$LOGPATH/rep_commitment_load
echo "lcd $LOGPATH">>$LOGPATH/rep_commitment_load
sqlplus -s $ORAUSER <<EOF >OUTPUTLOGFILE
@$SCRIPTDIR/rep_commitment_load.sql
EOF
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"

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 $DATEFILEPATH >> $OUTPUTLOGFILE
echo "
================================================================
Rep Commitment Load process failed with ORA errors.
Please check log file - $OUTPUTLOGFILE
================================================================="
exit 1
fi
exit 0
fi
exit;
##############################################################################


I am able to call the sql file., but the files not getting moved to OLDDATAPATH ., from the for loop.,

Please look after and help me out.

Raja
  #5 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
So what do you get if you run a pared-down version like this one?

Code:
#!/bin/ksh
cd /sharedapps/etlusr/etl/ftp/
pwd  # for debugging
temp=`ls ORD*`
for prevfile in $temp; do
  echo "# file: $prevfile"  # for debugging
  prevfile=$prevfile.`date +%D%H%M%S`
  echo mv $prevfile $OLDDATAPATH  # note echo for debugging
done
Error messages? Incorrect output? Magically wake up in Tahiti and none of this seems like much of a problem any longer?

Last edited by era; 03-27-2008 at 02:21 PM.. Reason: Add cd to right directory
  #6 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Never mind that, you are not defining OLDDATAPATH anywhere so it cannot work
  #7 (permalink)  
Old 03-27-2008
konankir konankir is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 9
The OLDDATAPATH is an environmental variable ., the path will be referred from the env file .,

Raja
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 01:57 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