why the below script is not working .,


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting why the below script is not working .,
# 1  
Old 03-27-2008
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  
Old 03-27-2008
What's the purpose of the for loop? Is $temp a wildcard or something?

How is it not working?
# 3  
Old 03-27-2008
Quote:
Originally Posted by konankir
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  
Old 03-27-2008
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  
Old 03-27-2008
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 03:21 PM.. Reason: Add cd to right directory
# 6  
Old 03-27-2008
Never mind that, you are not defining OLDDATAPATH anywhere so it cannot work
# 7  
Old 03-27-2008
The OLDDATAPATH is an environmental variable ., the path will be referred from the env file .,

Raja
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with speeding up my working script to take less time - how to use more CPU usage for a script

Hello experts, we have input files with 700K lines each (one generated for every hour). and we need to convert them as below and move them to another directory once. Sample INPUT:- # cat test1 1559205600000,8474,NormalizedPortInfo,PctDiscards,0.0,Interface,BG-CTA-AX1.test.com,Vl111... (7 Replies)
Discussion started by: prvnrk
7 Replies

2. UNIX for Beginners Questions & Answers

Why is this script not working?

for file in $(find /home/p611568/*.rpt -mtime -2 | grep -v ftplog) do awk '$1 == "XifPages," {PAGE = $5} $1 == "XifEndOfDocuments," {LINE = $5} index($0,"Value") && index($1,"Info") {sevGTI = 1} END {if (sevGTI) printf "%7s%10s%s",PAGE,LINE ... (4 Replies)
Discussion started by: bcarosi
4 Replies

3. Shell Programming and Scripting

Script not working

Hi i have write the one scripts and the scripts is error. The scripts purpose select one directory to check the file is there or not. i will give the two format of file to search the mention the path one file is there to select the file one copy the another location.please check the my script give... (1 Reply)
Discussion started by: rajivgandhi
1 Replies

4. UNIX for Dummies Questions & Answers

My script is not working

Hi All, I am trying to calculate the total_amount based on two key fields. Here is the script. I am new to unix. So please help me to find out the error in this script. I'm getting error like "command not found" and ]; is missing.. PRE_LBNO=0 PRE_DATE=0 TOT_PAY=0 for line in `cat... (4 Replies)
Discussion started by: lathanandhini
4 Replies

5. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: temp.sh su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

6. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

7. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

8. Shell Programming and Scripting

HELP !! script not working..

Hi all, I have a piece of code which cork perfect. It copy the no of lines from some files (*.log) into finalLog file. It read the lines after the line have text "ntot". Here it is : #!/bin/bash ... (10 Replies)
Discussion started by: nrjrasaxena
10 Replies

9. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

10. Shell Programming and Scripting

Script not working..."sort" not working properly....

Hello all, I have a file - 12.txt cat 12.txt =============================================== Number of executions = 2 Total execution time (sec.ms) = 0.009883 Number of executions = 8 Total execution time (sec.ms) = 0.001270 Number of... (23 Replies)
Discussion started by: Rahulpict
23 Replies
Login or Register to Ask a Question