Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Works... | 17 comments | Create New Account
Click here to return to the 'Works...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Works...
Authored by: mholve on Jan 29, '03 10:58:47AM

It works in your tcsh environment because it's a bash script (calling bash on the first line). So regardless of your shell, this script should work.

The script works nicely - thanks! :)



[ Reply to This | # ]
paths problem
Authored by: Anonymous on Jan 29, '03 12:11:54PM

When I type 'mywhois apple.com' I get: "mywhois: Command not found." But if I type the whole path to the script, it runs just fine. I seem to remember there being a shell preference I can set to have it automagically look in /usr/bin/ for commands, but I can't remember how to do it. Can someone refresh my memory?



[ Reply to This | # ]
paths problem
Authored by: Anonymous on Jan 29, '03 12:15:48PM

whoops. Nevermind I remembered it. For those who don't know, you can create a .tshrc file in your home directory with this line:

setenv PATH /usr/bin:$PATH

or

setenv PATH /usr/local/bin:$PATH

for stuff there. Works great, though I don't know if this is the way you're "supposed" to do it.



[ Reply to This | # ]
Use 'rehash'
Authored by: owain_vaughan on Jan 30, '03 06:41:50AM

/usr/bin should already be in your PATH, but in C-type shells you need to do a 'rehash' after putting new executables in a PATH directory. As a matter of neatness, non-system executables should go in /usr/local/bin anyway :)



[ Reply to This | # ]
Don't change your path!
Authored by: mholve on Jan 30, '03 09:38:34AM

You don't want to muck with your path, and don't have to.

To execute this script, wherever it is, use "./mywhois foo.com" or put the script somewhere that IS in your path, preferably something like "/usr/local/bin."

Make sure that once the script is entered, to do a "chmod 755 mywhois" to make it executable.



[ Reply to This | # ]
equivalent 1-liners
Authored by: mkhaw on Jan 29, '03 12:52:21PM

Some more directly 1-step alternatives:

1) (t)csh alias (typed all on one line):
alias whois "\whois -h "'`\whois \!:1 | sed -n '"s'/.*Whois Server: //p'"'` \!:1'

The funky mix of double- and single-quotes is to get around shell expansion and interpretation of special characters during the definition of the alias itself.

2) Equivalent /bin/sh 'mywhois' script:
#!/bin/sh
whois -h `whois $1 | sed -n 's/.*Whois Server: //p'` $1

3) Equivalent bash 'mywhois' shell function:
mywhois () {
whois -h `whois $1 | sed -n 's/.*Whois Server: //p'` $1
}

In (2) and (3) if you replace the 'whois' within the pipe with the full pathname of the real whois program (e.g., /usr/bin/whois) you can name the script/shell function itself 'whois'.



[ Reply to This | # ]