[K12OSN] Way OT: scripting help

Dimitri Yioulos dyioulos at firstbhph.com
Tue May 22 20:00:03 UTC 2007


On Tuesday 22 May 2007 3:51 pm, Huck wrote:
> is there some way to do an MD5 checksum on the file before and after?
> compare the two?
>
> --Huck
>
> Dimitri Yioulos wrote:
> > Hi, Folks.
> >
> > If it's appropriate (and if not, thanks for listening), I was wondering
> > if anyone would be kind enough to take time out of his/her busy day to
> > help me with a shell script (which I have little experience writing,
> > unfortunately, but I'm learning) which I need asap.  Here's the scenario:
> >
> > Our company copies a data file from Fileserver to FTPserver.  A business
> > partner picks up that file from the FTPserver at a specified time and,
> > with 10-15 minutes, returns a reults file.  The results file is then
> > copied to Fileserver, where it's made available to our business
> > application.  Finally, files older than 1 day are deleted from FTPserver.
> >
> > What I'd like to do is confirm that an exact copy is made from FTPserver
> > to Fileserver before deleting the old files,  But, I don't know how.
> >
> > Here's my script, simple as it is, so far:
> >
> > #!/bin/bash
> > #Declare our variables
> > FILENAME_PARTNER="partner"`eval date +%Y%m%d`".csv"
> > FILENAME_OURCOMPANY="ourcompany"`eval date +%Y%m%d`".csv"
> > WORKDIR=/home/partner
> > DAYSOLD="1"
> >
> > #Virus scan all files in Partner ftp directory
> > bdc --log=/var/log/bdc.log --disinfect $WORKDIR > /dev/null 2>&1
> >
> > #Change ownership and permissions of Ourcompany files to go to Partner
> > chown partner $WORKDIR/$FILENAME_OURCOMPANY
> > chgrp partner $WORKDIR/$FILENAME_OURCOMPANY
> > chmod 770 $WORKDIR/$FILENAME_OURCOMPANY
> >
> > #See if Partner file has been uploaded.  If not, wait 15 minutes, then
> > #transfer the file to Fileserver.  Scp authentication is automated.
> > if [ ! -f "$FILENAME_PARTNER" ]
> > then
> > sleep 900
> > elif [ -f "$FILENAME_PARTNER" ]
> > then
> > scp $WORKDIR/$FILENAME_PARTNER
> > root at fileserver:/data1/Application/partner/ break
> > else
> > scp $WORKDIR/$FILENAME_PARTNER
> > root at fileserver:/data1/Application/partner/ fi
> >
> > #Delete any files older than 1 day
> > if [ -d $WORKDIR ]
> > then
> >   find $WORKDIR -maxdepth 1 -mtime +$DAYSOLD -exec rm {} \;
> > else
> >   echo "$WORKDIR does not exist or is not a directory."
> > fi
> >
> > Exit 0
> >
> >
> > Again, your help would be greatly appreciated.
> >
> > Dimitri
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>


I would guess there is, but how do I compare the file on the remote box with 
that on the ftp server?  What is that mechanism?  What would the script code 
look like?  Therein lies my problem.

Dimitri

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the K12OSN mailing list