![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Improving Performance Through Persistent Connections | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 02:10 AM |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 12:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 12:06 AM |
| Improving Unix Skills | sak900354 | UNIX for Dummies Questions & Answers | 3 | 06-26-2006 02:03 PM |
| improving my script (find & replace) | amir_yosha | UNIX for Dummies Questions & Answers | 8 | 12-15-2003 07:31 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi;
I want to access our customer database to retreive all clients that have as language index 2 or 3 and take their client number. My input is a file containing all client numbers. i access the data base using a function call "scpshow". The total number of clients i want to scan is 400 000 clients. I tried this script using 100 subscriber it took 40 sec, and around 7% cpu time. how can i improve my script to make it faster (IF it can ever be done). #! /usr/bin date for sub in `cat /tmp/sublist ` do lang=0 lang=`/IN/scp/test/scpshow/scpshow ul50 $sub | grep 'usr_int\[23\]' | awk '{print $2}'` if [ $lang -eq 2 ] || [ $lang -eq 3 ]; then echo $sub >> /tmp/target fi done date cut -c 16-26 /tmp/target >> /tmp/final thanks for your fast reply. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Replacing
Code:
for sub in `cat /tmp/sublist ` do ... done Code:
while read sub do ... done < /tmp/sublist If you're processing 400,000 records it's going to be slow whatever you do - you'd be better off writing it in C if you'll be running it often. Cheers ZB |
|
#3
|
||||
|
||||
|
What does the output from scpshow look like? And what shell are you really using? #!/usr/bin won't work.
|
|
#4
|
|||
|
|||
|
scpshow output
the output is C300090B901900096393111222
i am calling the script #> ksh scritpname and it works... Quote:
|
|
#5
|
||||
|
||||
|
You need to make that first line:
#! /usr/bin/ksh If the output of "scpshow ul50 $sub" is: C300090B901900096393111222 then I'm confused how the pipeline works. That grep is not going to match anything. And there is no 2nd field for awk to print. |
|
#6
|
|||
|
|||
|
sorry for miss-explanation
The output of scpshow is
. . . usr_int[0] 0 usr_int[1] 9 . . usr_int[23] 1 usr_int[24] 3 . . . i need to check the value of usr_int[23] if it is 2 or 3 i have to take stor the Sub. number. I call scpshow in following way >scpshow C300090B901900096393123345 <--"sub. numer" and the output is the full profile of this specific sub (shown above) and i need to get all subs whose usr_int[23] =2 or 3. the list of all sub. numbers is stored in the file "sublist". around 400,000 sub. |
|
#7
|
||||
|
||||
|
The fastest script would be:
Code:
#! /usr/bin/ksh
exec < sublist
while read sub ; do
/path/to/scpshow ul50 $sub | while read string lang ; do
[[ $string = 'usr_int[23]' ]] && break
done
[[ $lang = $2 || $lang = 3 ]] && echo $sub >> /tmp/target
done
exit 0
|
||||
| Google The UNIX and Linux Forums |