Computing.Net > Forums > Unix > c-shell

c-shell

Reply to Message Icon

Original Message
Name: pele
Date: January 23, 2002 at 10:09:06 Pacific
Subject: c-shell
Comment:

I have to write a scripted for work. I never had to this before. The program has to do with nslookup. What scriptrd could I write just so I could type the IP and not type nslookup then the IP. Like I said just so I could type the IP.


Report Offensive Message For Removal


Response Number 1
Name: James Boothe
Date: January 23, 2002 at 13:32:50 Pacific
Subject: c-shell
Reply: (edit)

Create a file with just one line in it:

nslookup -timeout=10 ${1:?Specify IP address}

Name the file "lookup" or whatever, but do not name it nslookup since that would conflict with the real command. Now enable the script for execution:

chmod 755 lookup

Then run it like this:

lookup 202.194.15.145

Note that the system could find another script in your PATH before it finds this one. To confirm which file it sees first in PATH, you can do:

which lookup


Report Offensive Follow Up For Removal

Response Number 2
Name: James Boothe
Date: January 23, 2002 at 13:58:50 Pacific
Subject: c-shell
Reply: (edit)

Sorry, that script will run in your default shell. It is valid for sh and ksh, but not for csh, and I see that the subject of your post is c-shell.

The first line of a script can specify which shell it is to run in. The following script will work for csh:

#!/bin/csh
if ( $1 == '' ) then
echo '\nUsage: lookup \n'
exit
endif
echo '**************************************'
nslookup -timeout=10 $1
echo '**************************************'

Make sure that /bin/csh is the proper location of your csh (you can do "which csh").


Report Offensive Follow Up For Removal

Response Number 3
Name: Sakis
Date: March 25, 2002 at 07:32:21 Pacific
Subject: c-shell
Reply: (edit)

"bin2dec" C-shell script
input : 1000111
output : 71
would u help me?


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: c-shell

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software