[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[K12OSN] Way OT: scripting help



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 fileserver:/data1/Application/partner/
break
else
scp $WORKDIR/$FILENAME_PARTNER root 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

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]