Re: Another (simpler) bash scripting question...

2002-04-24 Thread Bob Bell
On Wed, Apr 24, 2002 at 11:47:28AM -0400, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > If so, why would you use an array for this sort of thing. Way back > in time when I was taking Intro to Programming, they taught us to use > linked lists for this type of scenario where you didn't know up f

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Benjamin Scott
On Wed, 24 Apr 2002, at 11:47am, [EMAIL PROTECTED] wrote: > I'm interpreting this as an out-of-memory error as a result of too many > file names filling up an array? Is that an accurate interpretation of > this trace? No, what happened is that the heap management routines detected a corrupion

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Michael O'Donnell
>I'm interpreting this as an out-of-memory error as >a result of too many file names filling up an array? >Is that an accurate interpretation of this trace? Nope - this problem was detected (though not necessarily caused) in the implementation of malloc()/free() that comes with the bash sourc

Re: Another (simpler) bash scripting question...

2002-04-24 Thread pll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-Type: text/plain; charset=us-ascii In a message dated: Wed, 24 Apr 2002 11:32:38 EDT Michael O'Donnell said: >Ha! I haven't analyzed this yet (and might never) but running bash >under GDB (actually, I attached GDB to the child bash proc) y

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Ben Boulanger
This is a VAX system you're trying it on?!? :) On Wed, 24 Apr 2002, Benjamin Scott wrote: > Try "xyzzy". ;-) * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body.

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Michael O'Donnell
Ha! I haven't analyzed this yet (and might never) but running bash under GDB (actually, I attached GDB to the child bash proc) yields: Program received signal SIGABRT, Aborted. 0x400497b1 in kill () from /lib/libc.so.6 (gdb) where #0 0x400497b1 in kill () from /lib/libc.so.6 #1 0x40049

Re: Another (simpler) bash scripting question...

2002-04-24 Thread pll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-Type: text/plain; charset=us-ascii In a message dated: Wed, 24 Apr 2002 11:02:46 EDT Michael O'Donnell said: >...then > > Every program can be reduced to one > instruction that does not work. I thought it was: Every program ca

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Michael O'Donnell
pll wrote: >> while true ; do /bin/true ; done > >I think there's a bug here. Nothing happens, well, at least not so far... ;) Well, we ARE getting pretty minimalistic here. Of course, if it's true that Every program has at least one bug. ...and Every program can be reduced in

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Benjamin Scott
On Wed, 24 Apr 2002, at 10:57am, [EMAIL PROTECTED] wrote: > Nothing happens ... Try "xyzzy". ;-) -- Ben Scott <[EMAIL PROTECTED]> | The opinions expressed in this message are those of the author and do not | | necessarily represent the views or policy of any other person, entity or | | orga

Re: Another (simpler) bash scripting question...

2002-04-24 Thread pll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-Type: text/plain; charset=us-ascii In a message dated: Wed, 24 Apr 2002 10:53:58 EDT Benjamin Scott said: > Try: > > while true ; do /bin/true ; done I think there's a bug here. Nothing happens, well, at least not so far... ;) - --

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Benjamin Scott
On Wed, 24 Apr 2002, at 10:43am, Michael O'Donnell wrote: > ...a memory leak somewhere in the fork() path? Try: while true ; do /bin/true ; done -- Ben Scott <[EMAIL PROTECTED]> | The opinions expressed in this message are those of the author and do not | | necessarily represent the

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Michael O'Donnell
Interesting: find . -type f | while read f; do true $f ; done #Builtin - works find . -type f | while read f; do /bin/true $f ; done #Chokes ...a memory leak somewhere in the fork() path? * To unsubscribe from t

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Benjamin Scott
On Wed, 24 Apr 2002, at 10:09am, Michael O'Donnell wrote: > Here's what I do to cause bash to say "Segmentation fault" > >cd / >find . -type f | while read f >do >ls -laFd $f >done Here are some test cases to try... Test 'read' in a loop: yes | while read f

Re: Another (simpler) bash scripting question...

2002-04-24 Thread Michael O'Donnell
Dang it! I may coincidentally have just found a fairly profound bash bug related to usage of that "spew | while read" idiom. Here's what I do to cause bash to say "Segmentation fault" cd / find . -type f | while read f do ls -laFd $f done Collecting the list in a file fir

Re: Another (simpler) bash scripting question...

2002-04-23 Thread Benjamin Scott
On Tue, 23 Apr 2002, at 11:00am, Michael O'Donnell wrote: >> This is a classic example of why I prefer doing actual >> script work in ksh and have my login shell as bash. > > Aren't you just saying that you prefer to stick with a familiar set of > idiosyncracies for scripting purposes? Heh. T

Re: Another (simpler) bash scripting question...

2002-04-23 Thread Michael O'Donnell
>This is a classic example of why I prefer doing actual >script work in ksh and have my login shell as bash. Aren't you just saying that you prefer to stick with a familiar set of idiosyncracies for scripting purposes? * To unsu

Re: Another (simpler) bash scripting question...

2002-04-23 Thread Kevin D. Clark
"Derek D. Martin" <[EMAIL PROTECTED]> writes: > At some point hitherto, Kevin D. Clark hath spake thusly: > > In general, the inner part of the loop is run in a sub-shell. > > Not exactly... it's more subtle even than that. For example: Yes, my language could have been a little tighter there

Re: Another (simpler) bash scripting question...

2002-04-23 Thread Steven W. Orr
On Mon, 22 Apr 2002, Derek D. Martin wrote: =>-BEGIN PGP SIGNED MESSAGE- =>Hash: SHA1 => =>At some point hitherto, Kevin D. Clark hath spake thusly: =>> >result=badness# init with failure default =>> >spewSomeKindOfOutput | while read input =>> >do =>> >result=good

Re: Another (simpler) bash scripting question...

2002-04-23 Thread pll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-Type: text/plain; charset=us-ascii In a message dated: Mon, 22 Apr 2002 17:48:27 EDT Benjamin Scott said: >On Mon, 22 Apr 2002, at 2:15pm, [EMAIL PROTECTED] wrote: >> If they only exist within bash, then I wouldn't advocate their use if >>

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Derek D. Martin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 At some point hitherto, Benjamin Scott hath spake thusly: > If portability is a concern, depending on the environment, it is sometimes > easier to install the GNU tools everywhere than try to craft something that > works on all the "native" tools.

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Derek D. Martin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 At some point hitherto, Kevin D. Clark hath spake thusly: > >result=badness# init with failure default > >spewSomeKindOfOutput | while read input > >do > >result=goodness > >done > >echo $result > > > > What is the out

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Jerry Feldman
In general, I try to write my scripts portable so that I can use them on other platforms. In the past 5 years, I have had jobs with Tru64 Unix, HP- UX (10.20 and 11.x), Solaris (7 and 8), and Linux (Debian, Red Hat and SuSE). Most of my personal scripts are small and work across platform. My mo

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Benjamin Scott
On Mon, 22 Apr 2002, at 2:15pm, [EMAIL PROTECTED] wrote: > If they only exist within bash, then I wouldn't advocate their use if > you're goal is portable shell code. If portability is a concern, depending on the environment, it is sometimes easier to install the GNU tools everywhere than try t

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Bob Bell
On Mon, Apr 22, 2002 at 05:15:00PM -0400, Mansur, Warren <[EMAIL PROTECTED]> wrote: > > No? Then how about this? > > > >result=badness# init with failure default > >spewSomeKindOfOutput | while read input > >do > >result=goodness > >done > >echo $result > > > >

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Kevin D. Clark
[EMAIL PROTECTED] (Michael O'Donnell) writes: > >it has a subtle scoping gotcha that drove me nuts the > >first time I tripped over it - anybody know what I'm > >referring to? > > No? Then how about this? > >result=badness# init with failure default >spewSomeKindOfOutput | while r

RE: Another (simpler) bash scripting question...

2002-04-22 Thread Mansur, Warren
> echo -ne 'line 1\nline 2\n' | while read foo ; do echo $foo ; done > Thanks to all for their answers. I've always wanted to do this but didn't know how until now. Works like a charm! Warren * To unsubscribe from this list, send

RE: Another (simpler) bash scripting question...

2002-04-22 Thread Mansur, Warren
> No? Then how about this? > >result=badness# init with failure default >spewSomeKindOfOutput | while read input >do >result=goodness >done >echo $result > > What is the output? badness Lemme guess. The pipe to the while actually creates a child process, and a

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Michael O'Donnell
>it has a subtle scoping gotcha that drove me nuts the >first time I tripped over it - anybody know what I'm >referring to? No? Then how about this? result=badness# init with failure default spewSomeKindOfOutput | while read input do result=goodness done echo $result

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Michael O'Donnell
That idiom (just mentioned here) where you do something like spewSomeKindOfOutput | while read input do somethingWith $input done ...does indeed work and I use it all the time, but it has a subtle scoping gotcha that drove me nuts the first time I tripped over it - anybody kno

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Bob Bell
On Mon, Apr 22, 2002 at 02:15:14PM -0400, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > In a message dated: Mon, 22 Apr 2002 14:03:32 EDT > Bob Bell said: > > >Look at the bash man page for '#', '##', '%', and '%%'. > > Are these "built-ins" also available in the real Bourne Shell, and/or k

RE: Another (simpler) bash scripting question...

2002-04-22 Thread Jerry Feldman
I have not tried it, but what about setting IFS to newline only. n 22 Apr 2002 at 14:42, Mansur, Warren wrote: > >> Does anyone know how to loop through each line instead, so that the output would >be > line 1 > line 2 > ? Thanks. -- Jerry Feldman <[EMAIL PROTECTED]> Associate Director Boston

Re: Another (simpler) bash scripting question...

2002-04-22 Thread John Abreau
"Mansur, Warren" <[EMAIL PROTECTED]> writes: > Does anyone know how to loop through each line instead, so that the output would be > line 1 > line 2 > ? Thanks. > echo -ne 'line 1\nline 2\n' | while read foo ; do echo $foo ; done -- John Abreau / Executive Director, Boston Linux & Unix ICQ

RE: Another (simpler) bash scripting question...

2002-04-22 Thread Mansur, Warren
> Yuck, yuck, yuck! It looks like everyone was pointing out ways to > use sed to accomplish this. Now, sed may give you extra > power, but when > writing shell scripts, I prefer to avoid using external commands where > possible. To that extent, consider: > > $ foo="1234M /home/USER" > $ e

Re: Another (simpler) bash scripting question...

2002-04-22 Thread pll
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Content-Type: text/plain; charset=us-ascii In a message dated: Mon, 22 Apr 2002 14:03:32 EDT Bob Bell said: >Look at the bash man page for '#', '##', '%', and '%%'. Are these "built-ins" also available in the real Bourne Shell, and/or ksh? Or

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Bob Bell
On Mon, Apr 22, 2002 at 12:16:15PM -0400, Brian Chabot <[EMAIL PROTECTED]> wrote: > On Mon, 22 Apr 2002 [EMAIL PROTECTED] wrote: > > > I said: > > > > > in other words, given: "1234M /home/USER" I want "USER" so as to then turn > > > around and email that user. (I already have > > > way of removi

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Brian Chabot
On Mon, 22 Apr 2002 [EMAIL PROTECTED] wrote: > I said: > > > in other words, given: "1234M /home/USER" I want "USER" so as to then turn > > around and email that user. (I already have > > way of removing non-user directories in /home). Woo hoo! Thanks for all the lightning fast help. I already

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Ben Boulanger
How about something like: du -sb ./*|sort -g|tail|sed 's/\.\///'|awk '{print $2}' to get the names... and then wrap it up in a mail command... it's not a "bash" script since it forks a few times, but it's a quick'n'dirty. Ben On Mon, 22 Apr 2002, Brian Chabot wrote: > Hey, all - > > I'm at

Re: Another (simpler) bash scripting question...

2002-04-22 Thread Michael O'Donnell
DISKHOG=`echo "1234M /home/USER" | sed -e 's;^.*/;;'` * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. ***