UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 6th, 2004, 05:43 AM
vinreston vinreston is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 vinreston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Looping through text file input with sybase queries

I have a take a text file input and scan through each line.
the contents of each line become a variable which I need to use to run some 15-20 queries against a Sybase db. The the loop should read next line for execution of same queries against this new variable(new line)

How do I go around this. I am new to scripting and this seems a relatively easy Q. All suggestions are welcome.

Reply With Quote
  #2  
Old October 6th, 2004, 06:21 AM
Muthukumar_K Muthukumar_K is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 13 Muthukumar_K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to Muthukumar_K
We can get line by line from a input file as,

while read line; do

echo $line

done < <inputfile>


Example:

Inputfile
-------
ls
hostname
uname -a


while read line; do

echo $line | sh

done < inputfile

It will execute every commands using with shell there. To make this to be used on sybase queries then,

while read line; do

query $line | sh

done < inputfile

IF you try to use as, query $line it will not be executed. IT will only print the query and $line string there. We are executing combined informations again with | sh there.

HTH.

REgards
Muthukumar

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Looping through text file input with sybase queries


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT