How can I do whois -r with a input file?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How can I do whois -r with a input file?
# 1  
Old 11-12-2010
MySQL How can I do whois -r with a input file?

Hello, I was wondering how I can do a whois from a file with lots of ip's in this format

0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0

And so on, then print the whois data from all the ip's to one single file sort of like this "whois -r 'ipfile' > 'whoisfile'"

Thanks in advance!

\Regards
# 2  
Old 11-12-2010
Code:
while read ip
do
     whois -r $ip
done<file

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 11-12-2010
EDIT: Sorry I didn't understand that "file" was the input file I thought it was the output .. Now it's working perfectly thank you!

Quote:
Originally Posted by ctsgnb
Code:
while read ip
do
     whois -r $ip
done<file

Hi, thanks for the fast reply.
Im sure im doing something wrong, but this is what I did..
I renamed my file with all the ips to 'ip' and put it in the same folder as my script, then I run it but I get this error

'./whois2.sh: line 5: file: No such file or directory'

here's the script:

#!/bin/bash
while read ip
do
whois -r $ip
done < file

Last edited by uxfuser; 11-12-2010 at 09:51 PM..
# 4  
Old 11-12-2010
1) create a file called ip_list and put all the IP addess in it (indeed, using the word "file" as a name is not a good idea since it is already a standard unix command).
2) create your script and run it :
Code:
#!/bin/bash
while read ip
do
     whois -r $ip
done<ip_list

Make sure you are in the right directory and that the file you specified exist in this directory
or use absolute file name.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Whois Lookup

Hi. I've just made our internal Whois lookup service available for all forum users, not only moderators and admins. Whois Database It's basically the same whois info you can get from your command line and many other web sites. If you would like to see other features, please post in... (0 Replies)
Discussion started by: Neo
0 Replies

2. Homework & Coursework Questions

Removing punctuations from file input or standard input

Just started learning Unix and received my first assignment recently. We haven't learned many commands and honestly, I'm stumped. I'd like to receive assistance/guidance/hints. 1. The problem statement, all variables and given/known data: How do I write a shell script that takes in a file or... (4 Replies)
Discussion started by: fozilla
4 Replies

3. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

4. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

5. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

6. Shell Programming and Scripting

whois country help

Hello folks, I have list of ips like 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 whois 1.1.1.1 |grep -E 'country|Country' it show country=US or whatever. so i have number of ips in text file, how i can use above script to automate output like 1.1.1.1 US 2.2.2.2 CA 3.3.3.3 FR (3 Replies)
Discussion started by: learnbash
3 Replies

7. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

8. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

9. Shell Programming and Scripting

whois scripting

Hi guys, I need a script that given an IP address, say IPA, do the following: - queries "whois IPA" - extracts, from the whois answer, the IP network string indicated after the string "route:", - searches the IP network string in a given text file, say CIDR2ASN.txt, which has several lines,... (1 Reply)
Discussion started by: stesecci
1 Replies

10. Shell Programming and Scripting

whois VS jwhois and timeout

I have a script that does a whois lookup that worked fine on a previous server. It used whois with the t option to timeout in 5 seconds. A while back I upgraded to a new server and the script had problems. I found out the new server didn't even have whois. The whois command was symlinked to jwhois... (4 Replies)
Discussion started by: PWSwebmaster
4 Replies
Login or Register to Ask a Question