* Re: counting shell args
@ 2002-12-16 22:04 johnjulian1
2002-12-17 15:05 ` Mike Dresser
0 siblings, 1 reply; 15+ messages in thread
From: johnjulian1 @ 2002-12-16 22:04 UTC (permalink / raw)
To: Mike Dresser, Scott Taylor; +Cc: linux-admin
Just a note responding to your comment about this being for backing up windows boxes. I back up ours with a script that does it in steps testing for errors along the way.
ping winbox
mount winbox /mnt/winbox
rsync /mnt/winbox user@remotebox
this doesn't compress but does give me a lot of error checking. The remote box in my case is a Solaris box with a big raid and tape jukebox.
If you're interested I'll email you the script.
Mike Dresser <mdresser_l@windsormachine.com> wrote:
>On Mon, 16 Dec 2002, Scott Taylor wrote:
>
>> That should be very useful to know. :)
>>
>> Now you have me curious (grr...I just got over that) why do you care if
>> there are more than 25 blocks in your zipped file?
>
>If it dumps out a zero byte file, as part of the pipe gzip will go gzip
>it, and it ends up being 20 bytes. As far as smbtar is concerned,
>that's a valid output, and returns 0 error code. It was easier to put
>down 25 than figure out if that's 25 bytes or 25 kilobytes.
>
>If it's a zero return code, AND the file is over 25(k), then the script
>rotates the backups, otherwise reports via email that there was a backup
>failure on that particular machine. Once in awhile I'll get one of those
>partial backups, and that's what the previous full daily backups are for.
>
>If i get two or so in a row, I go hunting down why the machine is
>failing(is it just turned off, is the ethernet unplugged AGAIN, did the
>hard drive die last Friday and the user hasn't called me after 4 days to
>tell me their computer is broken?)
>
>Are we still on topic? :D
>
>Mike
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: counting shell args
2002-12-16 22:04 counting shell args johnjulian1
@ 2002-12-17 15:05 ` Mike Dresser
0 siblings, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-17 15:05 UTC (permalink / raw)
To: johnjulian1; +Cc: Scott Taylor, linux-admin
On Mon, 16 Dec 2002 johnjulian1@netscape.net wrote:
> Just a note responding to your comment about this being for backing up windows boxes. I back up ours with a script that does it in steps testing for errors along the way.
> ping winbox
> mount winbox /mnt/winbox
> rsync /mnt/winbox user@remotebox
>
> this doesn't compress but does give me a lot of error checking. The remote box in my case is a Solaris box with a big raid and tape jukebox.
>
> If you're interested I'll email you the script.
I looked into using mount(smbmount), but ran into problems with smbmount
not keeping track properly of just how many files there are on a
filesystem. Been a problem ever since Samba 1.9.something at the minimum.
do 3 ls -alR's in a row, and it'll come up with different numbers each
time.
Even more odd than smbtar. :)
Mike
^ permalink raw reply [flat|nested] 15+ messages in thread
* counting shell args
@ 2002-12-16 20:36 Scott Taylor
2002-12-16 20:47 ` Mike Dresser
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Scott Taylor @ 2002-12-16 20:36 UTC (permalink / raw)
To: linux-admin
I'm sure I've seen, probably even use it before, but I can't remember or
find it now; does anyone remember how to count the number of arguments sent
to a bash script?
Like "if [ -z $3 ]; then" ... of corse that's for testing argument 3
exists, but how do I test if 3 arguments and only 3, are passed to the
script (or 1 or 10 or whatever).
Don't you just hate it when that happens. =P
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: counting shell args
2002-12-16 20:36 Scott Taylor
@ 2002-12-16 20:47 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161545230.25857-100000@router.windsormac hine.com>
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-16 20:47 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
On Mon, 16 Dec 2002, Scott Taylor wrote:
> I'm sure I've seen, probably even use it before, but I can't remember or
> find it now; does anyone remember how to count the number of arguments sent
> to a bash script?
$#
for example:
if [ $# -lt 2 ]; then
^ permalink raw reply [flat|nested] 15+ messages in thread[parent not found: <Pine.LNX.4.33.0212161545230.25857-100000@router.windsormac hine.com>]
* Re: counting shell args
[not found] ` <Pine.LNX.4.33.0212161545230.25857-100000@router.windsormac hine.com>
@ 2002-12-16 20:53 ` Scott Taylor
2002-12-16 20:57 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161555240.25857-100000@router.windsormac hine.com>
0 siblings, 2 replies; 15+ messages in thread
From: Scott Taylor @ 2002-12-16 20:53 UTC (permalink / raw)
To: linux-admin
At 12:47 PM 12/16/02, Mike Dresser wrote:
>On Mon, 16 Dec 2002, Scott Taylor wrote:
>
> > I'm sure I've seen, probably even use it before, but I can't remember or
> > find it now; does anyone remember how to count the number of arguments sent
> > to a bash script?
>
>$#
>
>for example:
>
>if [ $# -lt 2 ]; then
Man! That's been driving me nuts for like an hour now! Thanks. It's
still driving me nuts why I couldn't find it in man bash or man test though.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: counting shell args
2002-12-16 20:53 ` Scott Taylor
@ 2002-12-16 20:57 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161555240.25857-100000@router.windsormac hine.com>
1 sibling, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-16 20:57 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
On Mon, 16 Dec 2002, Scott Taylor wrote:
> >if [ $# -lt 2 ]; then
>
> Man! That's been driving me nuts for like an hour now! Thanks. It's
> still driving me nuts why I couldn't find it in man bash or man test though.
# Expands to the number of positional parameters in
decimal.
Doesn't exactly jump out and say, "HEY, I COUNT PARAMETERS"
I looked for many hours for that one myself when making a backup script.
Very annoying :)
Mike
^ permalink raw reply [flat|nested] 15+ messages in thread[parent not found: <Pine.LNX.4.33.0212161555240.25857-100000@router.windsormac hine.com>]
* Re: counting shell args
[not found] ` <Pine.LNX.4.33.0212161555240.25857-100000@router.windsormac hine.com>
@ 2002-12-16 21:05 ` Scott Taylor
2002-12-16 21:12 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161607130.25857-100000@router.windsormac hine.com>
0 siblings, 2 replies; 15+ messages in thread
From: Scott Taylor @ 2002-12-16 21:05 UTC (permalink / raw)
To: linux-admin
At 12:57 PM 12/16/02, Mike Dresser wrote:
>On Mon, 16 Dec 2002, Scott Taylor wrote:
>
> > >if [ $# -lt 2 ]; then
> >
> > Man! That's been driving me nuts for like an hour now! Thanks. It's
> > still driving me nuts why I couldn't find it in man bash or man test
> though.
>
># Expands to the number of positional parameters in
> decimal.
I saw that, and chose to ignore it, last time that happens. lol
>Doesn't exactly jump out and say, "HEY, I COUNT PARAMETERS"
No kidding. Heh, it's what happens when you run such a tight ship you
rarely need to do anything but play doom/quake to run those network tests. =P
>I looked for many hours for that one myself when making a backup script.
>Very annoying :)
Yeah, very. I remember once about 10 years ago someone told me that if I
study UNIX and can't find something, it's because the attitude is: "you
don't need to know that!" Now I know what he meant. Good thing it's no
longer like that. LMAO.
Cheers Mike.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: counting shell args
2002-12-16 21:05 ` Scott Taylor
@ 2002-12-16 21:12 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161607130.25857-100000@router.windsormac hine.com>
1 sibling, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-16 21:12 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
On Mon, 16 Dec 2002, Scott Taylor wrote:
> Yeah, very. I remember once about 10 years ago someone told me that if I
> study UNIX and can't find something, it's because the attitude is: "you
> don't need to know that!" Now I know what he meant. Good thing it's no
> longer like that. LMAO.
The worst part about writing this backup script of mine was finding the
return status from the previous pipe in the script.
smbtar -s $pcname -x $share -p $password -u $username -t - -X /win95 /win98 | gzip -1 > $filename.tar.gz
if [ $PIPESTATUS -eq 0 ] && [ `ls -s $filename.tar.gz | awk '{print $1}'` -gt 25 ]; then
$PIPESTATUS was hard to find.
All that because smbtar doesn't properly report errors, you have to
check that it did in fact report a zero error return, AND verify it
didn't just dump a 0 byte file cause the machine was unreachable. Even
so, if the Windows PC crashes in the middle of the backup(happens enough
to be annoying!), it'll still think the backup ran just fine, and dump a 0
status back at you, making the backup incomplete.
Most odd. :D
Mike
^ permalink raw reply [flat|nested] 15+ messages in thread[parent not found: <Pine.LNX.4.33.0212161607130.25857-100000@router.windsormac hine.com>]
* Re: counting shell args
[not found] ` <Pine.LNX.4.33.0212161607130.25857-100000@router.windsormac hine.com>
@ 2002-12-16 21:38 ` Scott Taylor
2002-12-16 21:49 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161645140.3389-100000@router.windsormach ine.com>
0 siblings, 2 replies; 15+ messages in thread
From: Scott Taylor @ 2002-12-16 21:38 UTC (permalink / raw)
To: linux-admin
At 01:12 PM 12/16/02, Mike Dresser wrote:
>On Mon, 16 Dec 2002, Scott Taylor wrote:
>
>The worst part about writing this backup script of mine was finding the
>return status from the previous pipe in the script.
>
>smbtar -s $pcname -x $share -p $password -u $username -t - -X /win95
>/win98 | gzip -1 > $filename.tar.gz
> if [ $PIPESTATUS -eq 0 ] && [ `ls -s $filename.tar.gz | awk
> '{print $1}'` -gt 25 ]; then
>
>$PIPESTATUS was hard to find.
That should be very useful to know. :)
Now you have me curious (grr...I just got over that) why do you care if
there are more than 25 blocks in your zipped file?
>All that because smbtar doesn't properly report errors, you have to
>check that it did in fact report a zero error return, AND verify it
>didn't just dump a 0 byte file cause the machine was unreachable.
quite painful.
>Even
>so, if the Windows PC crashes in the middle of the backup(happens enough
>to be annoying!), it'll still think the backup ran just fine, and dump a 0
>status back at you, making the backup incomplete.
Even better if the WinThing crashes on a Windows user that uses file names
like:
"This is my file that has numbers in it from last year end" on a set of
subdirectories that make the filename over 250 chars long.
Yes, I've seen that! LMAO Just try to recover that from your tar file. Ugly!
>Most odd. :D
Yes, the SMB/CIFS world is not a perfect world, but just look at what they
are trying to perfect. ;0)
Scott.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: counting shell args
2002-12-16 21:38 ` Scott Taylor
@ 2002-12-16 21:49 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161645140.3389-100000@router.windsormach ine.com>
1 sibling, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-16 21:49 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
On Mon, 16 Dec 2002, Scott Taylor wrote:
> That should be very useful to know. :)
>
> Now you have me curious (grr...I just got over that) why do you care if
> there are more than 25 blocks in your zipped file?
If it dumps out a zero byte file, as part of the pipe gzip will go gzip
it, and it ends up being 20 bytes. As far as smbtar is concerned,
that's a valid output, and returns 0 error code. It was easier to put
down 25 than figure out if that's 25 bytes or 25 kilobytes.
If it's a zero return code, AND the file is over 25(k), then the script
rotates the backups, otherwise reports via email that there was a backup
failure on that particular machine. Once in awhile I'll get one of those
partial backups, and that's what the previous full daily backups are for.
If i get two or so in a row, I go hunting down why the machine is
failing(is it just turned off, is the ethernet unplugged AGAIN, did the
hard drive die last Friday and the user hasn't called me after 4 days to
tell me their computer is broken?)
Are we still on topic? :D
Mike
^ permalink raw reply [flat|nested] 15+ messages in thread[parent not found: <Pine.LNX.4.33.0212161645140.3389-100000@router.windsormach ine.com>]
* Re: counting shell args
[not found] ` <Pine.LNX.4.33.0212161645140.3389-100000@router.windsormach ine.com>
@ 2002-12-16 22:18 ` Scott Taylor
2002-12-17 15:15 ` Mike Dresser
0 siblings, 1 reply; 15+ messages in thread
From: Scott Taylor @ 2002-12-16 22:18 UTC (permalink / raw)
To: linux-admin
At 01:49 PM 12/16/02, you wrote:
>On Mon, 16 Dec 2002, Scott Taylor wrote:
>
> > That should be very useful to know. :)
> >
> > Now you have me curious (grr...I just got over that) why do you care if
> > there are more than 25 blocks in your zipped file?
>
>If it dumps out a zero byte file, as part of the pipe gzip will go gzip
>it, and it ends up being 20 bytes. As far as smbtar is concerned,
>that's a valid output, and returns 0 error code. It was easier to put
>down 25 than figure out if that's 25 bytes or 25 kilobytes.
Ok. But you are testing for blocks not bytes or KB. Not that it probably
matters at this point; blocks these days are usually 1K size anyhow.
>If it's a zero return code, AND the file is over 25(k), then the script
>rotates the backups, otherwise reports via email that there was a backup
>failure on that particular machine. Once in awhile I'll get one of those
>partial backups, and that's what the previous full daily backups are for.
Ah, I see. :)
>If i get two or so in a row, I go hunting down why the machine is
>failing(is it just turned off,
That's just plain annoying, but it's funny when they come to you and ask
for a recovery of some file they have been working on for the last 6 months. ;>
>is the ethernet unplugged AGAIN,
Damn janitors!
>did the hard drive die last Friday and the user hasn't called me after 4
>days totell me their computer is broken?)
That's annoying too, but just about as funny as turning it off. I like to
send them to their boss to explain how much work they have accomplished in
that case. Yet, if it is the boss, I just take my time getting a
replacement. =P
>Are we still on topic? :D
Doesn't quite seem like it, but it's been interesting, nonetheless. ;)
Scott.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: counting shell args
2002-12-16 22:18 ` Scott Taylor
@ 2002-12-17 15:15 ` Mike Dresser
0 siblings, 0 replies; 15+ messages in thread
From: Mike Dresser @ 2002-12-17 15:15 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
On Mon, 16 Dec 2002, Scott Taylor wrote:
> >is the ethernet unplugged AGAIN,
>
> Damn janitors!
Janitors? I get the users unplugging their machines. Had one guy
complain his floppy drive and cdrom were broken. I go up to the plant(2
hour drive each way), and there's no screws on the case, the floppy drive
is fubar, and the cdrom isn't even plugged in, and if it were, it wouldn't
work anyways cause it was set to Master with the hard drive on the same
cable set to master. And the ethernet cable hanging from the wall.
Guy put a TV tuner card in his machine by himself. (pentium 200 too)
Got stuck when he had no network, no floppy drive, and no cdrom to install
drivers with.
We don't even have soundcards in the machines, why did he think we'd allow
a TV Tuner board?
He won't be doing that again. He's stuck with his 5" b&w portable now.
Mike
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: counting shell args
2002-12-16 20:36 Scott Taylor
2002-12-16 20:47 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161545230.25857-100000@router.windsormac hine.com>
@ 2002-12-17 3:11 ` dashielljt
[not found] ` <Pine.LNX.4.50.0212162211130.217-100000@athame.gmpexpress.n et>
3 siblings, 0 replies; 15+ messages in thread
From: dashielljt @ 2002-12-17 3:11 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
Check argc for a value once script has started.
Jude <dashielljt(at)gmpexpress-dot-net>
^ permalink raw reply [flat|nested] 15+ messages in thread[parent not found: <Pine.LNX.4.50.0212162211130.217-100000@athame.gmpexpress.n et>]
end of thread, other threads:[~2002-12-18 4:13 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-16 22:04 counting shell args johnjulian1
2002-12-17 15:05 ` Mike Dresser
-- strict thread matches above, loose matches on Subject: below --
2002-12-16 20:36 Scott Taylor
2002-12-16 20:47 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161545230.25857-100000@router.windsormac hine.com>
2002-12-16 20:53 ` Scott Taylor
2002-12-16 20:57 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161555240.25857-100000@router.windsormac hine.com>
2002-12-16 21:05 ` Scott Taylor
2002-12-16 21:12 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161607130.25857-100000@router.windsormac hine.com>
2002-12-16 21:38 ` Scott Taylor
2002-12-16 21:49 ` Mike Dresser
[not found] ` <Pine.LNX.4.33.0212161645140.3389-100000@router.windsormach ine.com>
2002-12-16 22:18 ` Scott Taylor
2002-12-17 15:15 ` Mike Dresser
2002-12-17 3:11 ` dashielljt
[not found] ` <Pine.LNX.4.50.0212162211130.217-100000@athame.gmpexpress.n et>
2002-12-17 15:38 ` Scott Taylor
2002-12-18 4:13 ` dashielljt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.