Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copying multiple files with "If Then Else" logic Post 302204730 by madhunk on Thursday 12th of June 2008 10:53:44 AM
Old 06-12-2008
Thanks Joey...

I did create a filename with the list of files that need to be copied...But I don't see much of a change in code because I am getting a count of records for each file and also using AWK to print the date part and then writing it to the log...

I am just trying to find an efficient way to write the code.

Code:
while read FILENAME
do
  cp -f ${FTP}/$FILENAME ${EXPORT}/${FILENAME}
  if [ $? -eq 0 ] 
  then
   DAY=$(ll $FTP | awk '/fwsalrpt.textp/ {print $6 $7 substr($8,1,5)}' )
   echo "*** FTP file from $DAY "  >>  $LOG
   RECORDS=$(cat $FTP/fwsalrpt.textp |wc -l )
   echo '*** Number of ftp fwsalrpt.textp records = ' $RECORDS >> $LOG
   if [ $RECORDS -lt 1 ]
   then
      echo "*** No data in input file "  >>  $LOG
      echo "*** nz.fwcsales.rplftp.job failed "  >> $LOG
      date >> $LOG
      exit 3
   fi
else
   echo "*** Copy of IBM file aborted"  >> $LOG
   echo "*** exit = " $RC  >> $LOG
   echo "*** nz.fwcsales.rplftp.job failed "  >> $LOG
   date >> $LOG
   exit 2
fi 

  cp -f ${FTP}/$FILENAME ${EXPORT}/${FILENAME}
  if [ $? -eq 0 ] 
  then
   DAY=$(ll $FTP | awk '/fwmslrpt.textp/ {print $6 $7 substr($8,1,5)}' )
   echo "*** FTP file from $DAY "  >>  $LOG
   RECORDS=$(cat $FTP/fwmsalrpt.textp |wc -l )
   echo '*** Number of ftp fwmsalrpt.textp records = ' $RECORDS >> $LOG
   if [ $RECORDS -lt 1 ]
   then
      echo "*** No data in input file "  >>  $LOG
      echo "*** nz.fwcsales.rplftp.job failed "  >> $LOG
      date >> $LOG
      exit 3
   fi
else
   echo "*** Copy of IBM file aborted"  >> $LOG
   echo "*** exit = " $RC  >> $LOG
   echo "*** nz.fwcsales.rplftp.job failed "  >> $LOG
   date >> $LOG
   exit 2
fi
done < {FTP}/fwcsales_filenames.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying all files of type "pdf"

Hi, Within a shell script I'm trying to copy all the files in a directory structure to another folder but only the files of type "pdf" I have made a start but I can't work out how to finish it. find $ATEBUILD/doc/user -name "*.pdf" | xargs cp THEN WHAT? I hope this makes sense! Rob (6 Replies)
Discussion started by: milage
6 Replies

2. Shell Programming and Scripting

Awk - to test multiple files "read" permission ?

Hi Masters, Iam new to this Forum and this is my first post. My question is: I've some datafiles belongs the type (A, B, C) in the location 'export/home/lokiman ' dataA1.txt dataB28.txt dataC35.txt 1) I've to check the read permission for each file, if it not there then I've to... (1 Reply)
Discussion started by: lokiman
1 Replies

3. UNIX for Advanced & Expert Users

Why is wget copying my directory tree with some files with "@"?

I'm using wget 1.11.4 on Cygwin 1.5.25. I'm trying to recursively download a directory tree, which is the root of a javadoc tree. This is approximately the command line I tried: wget -x -p -r http://<host>/.../apidoc When it finished, it seemed like it downloaded... (0 Replies)
Discussion started by: dkarr
0 Replies

4. Shell Programming and Scripting

Compiling multiple ".c" files starting with xxx

Hello, I am trying to figure out how I can write a bashscript that compiles several ".c" files that start with xxx (example: xxx_try.c and xxx_that.c) So I want to compile all these files with a bash script. Anyone can help pls? (6 Replies)
Discussion started by: Freak79
6 Replies

5. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Advanced & Expert Users

How to gzip files "on fly" before copying

Hello, I want to gzip some files before copying to remote host. There is no freespace on source host so it needs to be perfomed within one-liner. I tried the following but it didn't work gzip -c -9 all_rvds.xml |ssh targethost "dd of=/tmp/all_rvds.xml.gz" cat all_rvds.xml |gzip -c9 |ssh... (5 Replies)
Discussion started by: urello
5 Replies

8. Shell Programming and Scripting

Find out if multiple files have lines ending with"r"

I am trying to find out which files in a group of files have lines ending in r. What I have is this: cat /tmp/*RECORDS| if grep r$>/dev/null; then echo "yes";else echo"no";fi Records is more than one file. There are the following files TEST-RECORDS /volume/testing /volume/programs ... (2 Replies)
Discussion started by: newbie2010
2 Replies

9. UNIX for Advanced & Expert Users

"GET" command retrieves multiple files while using wildcard

Hi All I am using GNU/Linux This is regarding the get command to retrieve files (filename with wild card characters) from remote server. I thought Get command can retrieve only 1 file irrespective of the files it has on the remote server And it is the function of mget to retrieve all... (7 Replies)
Discussion started by: sparks
7 Replies

10. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
LOG(1)							     cao-vlsi reference manual							    LOG(1)

NAME
log - logical representations for boolean functions and utilities. ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr DESCRIPTION
log is a set of structures and functions that permits to manipulate several representations of boolean functions. Several programs and libraries of the cao-vlsi cad tools rest on the log package. Three different kind of functions are available for: Hash table management Prefixed representation for boolean functions Ordered binary decision diagrams representation EXAMPLE
Let's suppose that actual mbk version is 'nnn'. In order to use log, libMutnnn.a library must be called. makefile: HEADER = -I/labo/include LIB = -L/labo/lib -lMut -ltsh -labl -lbdd Each library can be called separatly. The "log.h" header file must be inserted in the files that use the functions or the structures defined in a library. SEE ALSO
mbk(1), beh(1), AUTHOR
L. BURGUN salle 30 T. 55-65 Universite P&M Curie - 4 pl. Jussieu - FRANCE THANKS
Thanks to P. REMY, F. PETROT, P. ALLEGRE and N. DICTUS. BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 October 1, 1997 LOG(1)
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy