[Chester LUG] Help with a bash script

Stuart Burns stuart.james.burns at gmail.com
Fri May 16 14:27:41 UTC 2008


Lol, The money for the tea and coffee funds, easier to use the blank cheques
lying around ;)

No, the purpose is to act as a (poor) interface between a MUMPS (aka Cache
Intersystems) DB and an IBM iSeries.

The files concern stock that needs to be reserved and passed from the
iSeries to the MUMPS system. So basically the iSeries drops a text file at
random intervals onto the FTP server and then the FTP server via the batch
script translates it into the correct format.

However I have discovered that numbering, as long as it is mmdxxxx where x
is unique, is fine. The RS at the beginning has special meaning in as much
as it is indicates a certain type of transaction. I therefore got the
required level of uniqueness by tacking %N on the end of the date var.

The final code I came up with (yet to be tested) is

mount //10.0.0.133/mumps /mnt/mumps -o username=xxx,xxx
cd /home/myftpusername/
DATE=`date +%m%u%N`
mv RS000001.001 RS$DATE.001
cp RS$DATE.001 Reserve/Backup/
mv RS$DATE.001 /mnt/mumps/DATA/DATA_OUT/
umount /mnt/mumps

And thanks to everyone who suggested an answer. I will have to take a look
at printf - looks a powerful command!



2008/5/16 Michael Crilly <e-mail at mcrilly.co.uk>:

> I agree with simon. Date would be better and it would make
> organisation easier. What does this for contain, by the way? What's it
> for, out of interest? Is it all the money you're filtering from the
> companies tea and coffee funds? :P
>
> On 5/16/08, Simon Willett <simonw at gbitsystems.co.uk> wrote:
> > Hi Stuart,
> >
> >
> >
> > A hack would be;
> >
> >
> >
> > COUNT=`ls RSmmd*001 | wc -w`
> >
> > COUNT=`expr $COUNT + 1`
> >
> > # COUNT now contains the number of files of type RSmmd + 1
> >
> >
> >
> > But you should really be using date +%Y%m%d you actually do want to
> pre-zero
> > the day, and you should also include the year, otherwise the process
> breaks
> > come the year end.
> >
> >
> >
> >
> >
> > Hope this helps,
> >
> > Simon
> >
> >   _____
> >
> > From: chester-bounces at mailman.lug.org.uk
> > [mailto:chester-bounces at mailman.lug.org.uk] On Behalf Of Stuart Burns
> > Sent: 15 May 2008 20:38
> > To: chester
> > Subject: [Chester LUG] Help with a bash script
> >
> >
> >
> > Hi Everyone.
> >
> > I need a little help with a batch file. I have managed a bit of it, but
> i'm
> > a bit lost now.
> >
> > What I need to do is
> >
> > 1.    Looks for file RS000001.001 in folder
> > 2.    Rename it RSmmdnnn.001 (mm=month, d= day number {Monday=1},
> > nnnn=unique count for the day)
> >
> > Now this file can appear up to several times a day (ie its going to run
> as a
> > cron job every half hour to pick up the files as they are dumped by ftp)
> I
> > can do the basic stuff with the date ie DATE = `date +%m%u` but setting
> up
> > the nnnn bit is where  I am getting lost.
> >
> > Any help appreciated.
> >
> > Stu
> >
> >
>
> --
> Sent from Google Mail for mobile | mobile.google.com
>
> M. T. Crilly
> http://www.mcrilly.co.uk/
>
> _______________________________________________
> Chester mailing list
> Chester at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/chester
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/chester/attachments/20080516/2d7cd373/attachment.html>


More information about the Chester mailing list