Need to execute the same statement

I have written a script for converting an IP address into its corresponding AS number in PHP. But based on the timing analysis, I've observed that it takes a long time to process large number of entries. So I need to do something directly in unix. What method would one suggest for this purpose?

Purpose:
There is a statement:
nc whois.sampleserver.com portnumber

After entering that, I need to enter the ip address and after entering it gives me the AS number in the forum of a line. I need to use regular expressions to capture the AS number and then store it in a file.

After this, I need to type that same command again and repeat the procedure.

Can someone please tell me what I have to do to achieve the above? Is it shell scripting or direct coding in languages like C?

The general format is

while :
do
cmd1
cmd2
..
sleep 60
done

In this case we'll sleep 60 seconds between executing commands.

For the second part (formatting the output), we'd need to know what you want it to look like.. but again rather generally:

..
cmd1 | filter_script >> somefile
..

Thanks. The output is in the form of xxxx | x.x.x.x | something else here. i was able to form a regular expression in php but I wanted to know where I can place such a thing here in unix.

what are "nc" and "AS"?

Oh... Sorry. I should've mentioned that. nc is netcat. And AS is just a number associated with an IP address. It tells if the IP address belongs to a particular ISP or not...

Prototype in shell script then I suggest Perl as that lets you handle regular expressions fairly easily.

Oh.. Ok..Thank you... Then I'll start reading Perl.. But will I be able to do all these with that?

Execute shell commands
Grab the output like the popen command you showed me yesterday
Work with regular expressions
Read and write into files
I was wondering if SQL commands can be executed

Thanks

Yes, all of those.

Thank you... I will start off with that... :slight_smile: