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 first

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

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 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: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 | |

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 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 can

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

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 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)

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

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 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 front

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-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. In

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

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. That is

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.

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

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 had most

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 removing non-user

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 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 $ echo

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 28611923

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 Linux

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 ksh? Or

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 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 child

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 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 read input

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 What is the output?

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 to

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

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 output? In

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.