zsh-users
 help / color / mirror / code / Atom feed
* (mime attachment!) debug function: first time weird behavior
@ 1998-02-27 20:58 Timothy J Luoma
  1998-02-27 21:52 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy J Luoma @ 1998-02-27 20:58 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

[An attachment was originally included here]

I have attached a function which I have been working on.

It archives information gathered from 'whois' (so I don't have to wait for  
internic to respond if I have already run 'whois' on the archive.

The first time it is run it says:

/usr/local/lib/whois/ is a directory
 whois: Have info archived: /usr/local/lib/whois/

If I run it again, it works fine.

I am totally clueless as to why this is happening but it is easily reproducable.

Any help greatly appreciated.

TjL

ps -- the file has long lines, which is why I didn't just paste it

[-- Attachment #2.1: openfiletmp000595 --]
[-- Type: application/octet-stream, Size: 1115 bytes --]

whois () {
	unsetopt ALL_EXPORT
	DIR=/usr/local/lib/whois 
	FILE=$DIR/$LOOKFOR 
	LOOKFOR=`echo $* | awk '{print $NF}'` 
	NAME="whois" 
	SERVERS=(rs.internic.net whois.arin.net whois.ripe.net whois.apnic.net whois.nic.mil) 
	TMP=/tmp/$NAME.$$ 
	WHOIS=/usr/ucb/whois 
	if [ -r $FILE ]
	then
		less $FILE
		echo " $NAME: Have info archived: $FILE\n"
	else
		FOUND=no 
		for i in $SERVERS
		do
			if [ "$FOUND" = "no" ]
			then
				/bin/rm -rf $TMP && $WHOIS -h "$i" $LOOKFOR | sed -n -e "/If you would like to search on arbitrary/q" -ep | sed -n -e "/The ARIN Registration Services Host/q" -ep | sed -n -e "/The InterNIC Registration Services Host/q" -ep | sed -n -e "/only contains DOD Information/q" -ep 2>& 1 > $TMP
				case $i in
					whois.ripe.net|whois.apnic.net) NOMATCH='No entries found'  ;;
					*) NOMATCH='No match for'  ;;
				esac
				fgrep -q -s "$NOMATCH" $TMP
				if [ "$?" = "1" ]
				then
					FOUND=yes 
					less $TMP
					echo "\n INFO obtained `date` from $i\n" >> $TMP
					command mv --interactive --verbose $TMP $FILE
				else
					echo "$i does not know $LOOKFOR"
				fi
			fi
		done
	fi
}

[-- Attachment #2.2: Type: text/enriched, Size: 566 bytes --]




I have attached a function which I have been working on.


It archives information gathered from 'whois' (so I don't have to wait for
internic to respond if I have already run 'whois' on the archive.

<nofill>
The first time it is run it says:

/usr/local/lib/whois/ is a directory
 whois: Have info archived: /usr/local/lib/whois/

If I run it again, it works fine.

I am totally clueless as to why this is happening but it is easily reproducable.

Any help greatly appreciated.

TjL

ps -- the file has long lines, which is why I didn't just paste it 
</nofill>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (mime attachment!) debug function: first time weird behavior
  1998-02-27 20:58 (mime attachment!) debug function: first time weird behavior Timothy J Luoma
@ 1998-02-27 21:52 ` Bart Schaefer
  1998-02-28  1:10   ` Timothy J Luoma
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1998-02-27 21:52 UTC (permalink / raw)
  To: Timothy J Luoma, zsh-users

On Feb 27,  3:58pm, Timothy J Luoma wrote:
> Subject: (mime attachment!) debug function: first time weird behavior
> 
> The first time it is run it says:
> 
> /usr/local/lib/whois/ is a directory
>  whois: Have info archived: /usr/local/lib/whois/
> 
> If I run it again, it works fine.
> 
> I am totally clueless

Er, yes. :-)

        DIR=/usr/local/lib/whois 
        FILE=$DIR/$LOOKFOR 
        LOOKFOR=`echo $* | awk '{print $NF}'` 

Have you considered that perhaps you should assign a value to LOOKFORE
-before- you use it to assign to another variable?

        DIR=/usr/local/lib/whois 
        LOOKFOR=`echo $* | awk '{print $NF}'` 
        FILE=$DIR/$LOOKFOR 

Also, you could use

	LOOKFOR=$*[$#]

instead of that horrible awk.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (mime attachment!) debug function: first time weird behavior
  1998-02-27 21:52 ` Bart Schaefer
@ 1998-02-28  1:10   ` Timothy J Luoma
  0 siblings, 0 replies; 3+ messages in thread
From: Timothy J Luoma @ 1998-02-28  1:10 UTC (permalink / raw)
  To: zsh-users

	Author:        "Bart Schaefer" <schaefer@brasslantern.com>
	Original-Date: Fri, 27 Feb 1998 13:52:45 -0800
	Message-ID:    <980227135245.ZM22520@candle.brasslantern.com>

> DIR=/usr/local/lib/whois
> FILE=$DIR/$LOOKFOR
> LOOKFOR=`echo $* | awk '{print $NF}'`
>
> Have you considered that perhaps you should assign a value to LOOKFORE
> -before- you use it to assign to another variable?


*beats self upside the head*

All I can claim as an excuse is that I've been up until about 6 or 7 all  
week working on a report


> Also, you could use
>
> 	LOOKFOR=$*[$#]
>
> instead of that horrible awk.

Oh!  Nifty!  Will do....

I still use /bin/sh for most scripting things so I haven't learned much of  
the zsh-isms.....

TjL


-- 
"It takes real courage to be a Macintosh user; it takes real
conviction; not unlike being a Christian in the days of the Romans." 
 - Guy Kawasaki, Chief Evangelist for Apple Computer - from "Hotseat"
   interview with John McChesney (3/28/97) [ my birthday! ]


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-02-28  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-27 20:58 (mime attachment!) debug function: first time weird behavior Timothy J Luoma
1998-02-27 21:52 ` Bart Schaefer
1998-02-28  1:10   ` Timothy J Luoma

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).