The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 01:14 PM
How do i execute in IF ELSE Statement laknar Shell Programming and Scripting 1 06-08-2007 02:54 AM
Script does not execute Insert Statement Amruta Pitkar Shell Programming and Scripting 4 08-24-2006 11:14 PM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 04:42 PM
How can I get an if statement to execute based on number of lines in a file? LordJezo Shell Programming and Scripting 6 05-14-2004 10:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-01-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
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?
  #2 (permalink)  
Old 10-01-2007
TonyLawrence TonyLawrence is online now
Registered User
  
 

Join Date: Sep 2007
Location: SE Mass
Posts: 68
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
..
  #3 (permalink)  
Old 10-01-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
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.
  #4 (permalink)  
Old 10-01-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
what are "nc" and "AS"?
  #5 (permalink)  
Old 10-01-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
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...
  #6 (permalink)  
Old 10-01-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by Legend986 View Post
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?
Prototype in shell script then I suggest Perl as that lets you handle regular expressions fairly easily.
  #7 (permalink)  
Old 10-01-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
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
Sponsored Links
Closed Thread

Bookmarks

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0