Sponsored Content
Top Forums Shell Programming and Scripting Need to execute the same statement Post 302138379 by Legend986 on Monday 1st of October 2007 10:04:44 AM
Old 10-01-2007
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?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I get an if statement to execute based on number of lines in a file?

I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for: $ ps -ef | grep wtrs --- webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies

2. Shell Programming and Scripting

Script does not execute Insert Statement

Hi I have a text file , contents are Line1:field1,field2,field3,field4,field5,field6.......field20 Line2:field1,field2,field3,field4,field5,field6.......field20 Line3:field1,field2,field3,field4,field5,field6.......field20 ....and so on... I want to read this file and insert the data into... (4 Replies)
Discussion started by: Amruta Pitkar
4 Replies

3. Shell Programming and Scripting

How do i execute in IF ELSE Statement

ls -ld /path/to/dir1 path/to/dir2 | awk '{print $8}' how to execute above script in IF ELSE Statement. Pls iam new to Unix (1 Reply)
Discussion started by: laknar
1 Replies

4. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

5. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

6. AIX

Controling a statement to execute

Hi All I have a script which runs a piece of JOB. The jobs are in sequence and if it fails at a particular job I wanted it to be started from the point where it failed. What I did I prepared two properties file one which contains the entire List of the JOBS which are to be executed and the... (5 Replies)
Discussion started by: Prashantckc
5 Replies

7. Shell Programming and Scripting

for each value in an array, execute select statement

Hello All, I am new to shell scripting. I am working on Solaris O/S, bash script and sybase programming. I want to loop through multiple values in an array and for each value, I want to select a row from the database. following is the code written for it. output="loop.csv" ... (8 Replies)
Discussion started by: arundhati_s
8 Replies

8. Shell Programming and Scripting

Execute and log each statement/block SQL file

Hi friends, I would like to get some help on the following requirement. I have a SQL file with following things, select 1 from dual; select user from dual; select sysdate from dual; BEGIN PL/SQL Code END; / This file will be saved as sql file. When I run my expected shell script,... (1 Reply)
Discussion started by: ssnair
1 Replies

9. Shell Programming and Scripting

How to pass tablenames from a file to shell script to execute create statement in DB2

Hi, I am new to Shell Scripting, and I need to create nicknames for 600 tables in db2. I have the file names in a text file and i have to pass these table names to a shell script create nicknames in db2. Can some one please help me in this regard. (1 Reply)
Discussion started by: kamalanaatha
1 Replies

10. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
regex(3)						     Library Functions Manual							  regex(3)

Name
       re_comp, re_exec - regular expression handler

Syntax
       char *re_comp(s)
       char *s;

       re_exec(s)
       char *s;

Description
       The  subroutine	compiles  a string into an internal form suitable for pattern matching.  The subroutine checks the argument string against
       the last string passed to

       The subroutine returns 0 if the string s was compiled successfully; otherwise a string containing an  error  message  is  returned.  If	is
       passed 0 or a null string, it returns without changing the currently compiled regular expression.

       The  subroutine returns 1 if the string s matches the last compiled regular expression, 0 if the string s failed to match the last compiled
       regular expression, and -1 if the compiled regular expression was invalid (indicating an internal error).

       The strings passed to both and may have trailing or embedded newline characters; they are terminated by	nulls.	 The  regular  expressions
       recognized are described in the manual entry for given the above difference.

Diagnostics
       The subroutine returns -1 for an internal error.

       The subroutine returns one of the following strings if an error occurs:

       No previous regular expression
       Regular expression too long
       unmatched (
       missing ]
       too many () pairs
       unmatched )

See Also
       ed(1), ex(1), egrep(1), fgrep(1), grep(1)

																	  regex(3)
All times are GMT -4. The time now is 01:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy