From owner-freebsd-questions Wed Oct 3 0:48:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-31-203-60.mmcable.com [65.31.203.60]) by hub.freebsd.org (Postfix) with SMTP id 1972137B403 for ; Wed, 3 Oct 2001 00:48:05 -0700 (PDT) Received: (qmail 35456 invoked by uid 100); 3 Oct 2001 07:47:59 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15290.49839.267477.132658@guru.mired.org> Date: Wed, 3 Oct 2001 02:47:59 -0500 To: questions@freebsd.org Subject: More scripting questions (Jack Stone - this is for you). X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG MAILER-DAEMON@guru.mired.org types: > Hi. This is the qmail-send program at guru.mired.org. > I'm afraid I wasn't able to deliver your message to the following addresses. > This is a permanent error; I've given up. Sorry it didn't work out. > > : > Connected to 216.122.141.44 but sender was rejected. > Remote host said: 501 ... Sender domain must exist Gee, it exists from where I sit...... --- Below this line is a copy of the message. > > Return-Path: > Received: (qmail 35030 invoked by uid 100); 3 Oct 2001 07:28:50 -0000 > From: Mike Meyer > MIME-Version: 1.0 > Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 7bit > Message-ID: <15290.48690.896387.668917@guru.mired.org> > Date: Wed, 3 Oct 2001 02:28:50 -0500 > To: jacks@sage-american.com > Cc: Mike Meyer > Subject: Re: Scripting question > In-Reply-To: <3.0.5.32.20011002133552.03f12c60@mail.sage-american.com> > References: <3.0.5.32.20010930161904.03f12c60@mail.sage-american.com> > <72642935@toto.iv> > <3.0.5.32.20011002133552.03f12c60@mail.sage-american.com> > X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid > X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% > *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ > > jacks@sage-american.com types: > > Mike, you were kind enough to offer some scripting ideas the other day. I > > am pleaased to say that I have in place now a script that changes the file > > suffix on another script, but I still have a non-script flat file that > > needs a monthly modification as the last step to finish up this thing. > > Here's more specifics: > > > > The flat file that contains the variable needed is contained in a macro > > line for FTPing using the .netrc file which is not a script. The line in > > the "macdef" line is this: > > > > #put myfile.01.09 #a file with year/month suffix > > > > So, I need a script to run on the first day of each month to somehow roll > > over the date suffix in the .netrc file FTP command line based on the date > > command `date +myfile.%y%m` Thus, the file now reads "put myfile.01.10" but > > I had to do it manually on the first day of the month. This comes up every > > month. Can't use the "date" variable in the FTP command line as it won't > > recognize the `date` command. So, something has to read that file and > > change that filename. Help appreciated..... thanks! > > You can do that one by hand: > > FILEFMT=myfile.%y.%m > newfile=$(date +$FILEFMT) > oldfile=$(date -r ($expr $(date +%s) - 86400) +$FILEFMT) > mv .netrc old.netrc > sed s/$oldile/$newfile/ .netrc > > which will do the trick. FWIW, $( ... ) is the same as ` ... `, except > you can nest them. > > However, since you are running the ftp from a script, it might be > better to take the transfer *out* of the .netrc - after all, you don't > want that to happen if you're ftping there for some other reason, do > you? You let the .netrc get you logged in, and replace the put command > with either an echo: > > echo put $filename | ftp REMOTESYSTEM > > or, if you need to do multiple commands, a here document: > > ftp REMOTESYSTEM < cd ARCHIVEDIR > put $filename > EOF > > The leading tab is just for illustration; the last line must not have > any blank spaces before the EOF. > > > -- > Mike Meyer http://www.mired.org/home/mwm/ > Q: How do you make the gods laugh? A: Tell them your plans. > -- Mike Meyer http://www.mired.org/home/mwm/ Q: How do you make the gods laugh? A: Tell them your plans. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message