help with using text file as input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with using text file as input
# 1  
Old 10-07-2011
help with using text file as input

Hello All,

I'm attempting to use a text file as input to a specific field in a command. Below is the command...

Typically it looks like this

Code:
ans_dump testzone.com channel=dnsw32 | grep AAAA

I have about 500 zones I want to check... how do I use my text file as input where the zone name would be? Thanks.
Code:
ans_dump <text file input here> channel=dnsw32


Last edited by radoulov; 10-07-2011 at 04:45 PM.. Reason: Code tags!
# 2  
Old 10-07-2011
Code:
while read LINE
do
        ans_dump "${LINE}" channel=dnsw32
done < inputfile

---------- Post updated at 12:36 PM ---------- Previous update was at 12:35 PM ----------

Depending on how ans_dump works it may be possible to run it fewer times, cramming more input into it, which would be more efficient, but I don't know anything about ans_dump. Can you put channel=... before the rest instead of after? Will it accept more than one name after it and do what you want?

---------- Post updated at 12:41 PM ---------- Previous update was at 12:36 PM ----------

Also, if you want to run grep on the output, you can do it collectively:

Code:
while read LINE
do
        ans_dump "${LINE}" channel=dnsw32
done < inputfile | grep whatever

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 10-07-2011
That worked perfectly. Grep doesn't seem to be filtering what I want but it is using the file as the source for the zones.

Below is the code i'm using.

Thank you!

Code:
while read LINE; do ans_dump "${LINE}" channel=dnsent01; done < dnsentzones.txt | grep AAAA

EDIT: Actually I was mistaken, the grep is working properly. Thanks again.
This User Gave Thanks to spartan22 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying a file to multiple other files using a text file as input

Hello, I have a file called COMPLIST as follows that contains 4 digit numbers.0002 0003 0010 0013 0015 0016 0022 0023 0024 0025 0027 0030 0031 0032 0033 0035 0038 0041 (3 Replies)
Discussion started by: sph90457
3 Replies

2. Shell Programming and Scripting

Add input to text file

In the attached bash file I am trying to add a block of code to add2text that will copy the input from match to a text file (file.txt). For example, if from the menu choice 1 is select the user is asked for the id.... lets say that is 12345, after that id is matched and converted can it be added... (22 Replies)
Discussion started by: cmccabe
22 Replies

3. Shell Programming and Scripting

How to give a text file as input while running a program?

Hi Friends, I am running a program /path/to/program -i 1 100 -o /path/to/output/op_1_100.txt In the above command, I have to try various number of combinations at the -i parameter and the output file name varies with each combination. Now, I have my -i parameter text file, which is like... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

4. Shell Programming and Scripting

Read text file and use it as input

I need to take a text file that holds a bunch of data and run each the stuff in it as an input for the program. the file would hold stuff like this: thing1.awesomesite.com 80 123.456 thing2.awesomesite.com 80 789.098 thing3.awesomesite.com 80 765.432 ... Now I already know the... (1 Reply)
Discussion started by: shade917
1 Replies

5. Shell Programming and Scripting

matching user input to a text file loop?

until do read -p "Invalid cars. Try againa" cars1 done Ok i have the above code, im getting users input and if it doesnt match in the file the user has to try again untill its correct But when i run this it gives me an error saying ./Cars.bash: line 43: (2 Replies)
Discussion started by: gangsta
2 Replies

6. Shell Programming and Scripting

input text at certain lines of a file

Hi, I have an xml file which will be edited by the user. I would like to get input from user and insert that at line 40 of the xml file. PLease can some one help me to know how to insert the text at specified line using shell script. (6 Replies)
Discussion started by: sunrexstar
6 Replies

7. Shell Programming and Scripting

How to redirect a input of find command into a text file

Hello friends, I want a command to print the reult files from find command into a text file.:) Iam looking from forum memebers. PLZ help me.ASAP Thanks in Advance, Siva Ranganath CH (5 Replies)
Discussion started by: sivaranga001
5 Replies

8. Shell Programming and Scripting

input text from file into 2d array

Hi all I have a little brainscratcher here. I want to draw a pie chart from data in a text file. The drawing of the graph works fine, if I insert the data manually into a 2d array. Now I want to pull the data from a text file (which was created using a uniq -c command) see sample below.... (2 Replies)
Discussion started by: pietie
2 Replies

9. Shell Programming and Scripting

Replace text in input file

I wish to replace values of specific parameters in an input file for batch runs of a java code. It's essentially a nested for-loop sorta like this: valuearray1 contains values for param1 valuearray2 contains values for param2 for (all values in valuearray1) go into specific position in... (2 Replies)
Discussion started by: daphantomica
2 Replies

10. Shell Programming and Scripting

input text into file

hello everyone, this is my first time posting here so be nice ;-) I am a bit new at unix scripting and have basically been hacking other peoples scripts to get them to do what I need. I have now hit a bit of a stop. This problem is very basic but I can't just seem to figure out how to get... (1 Reply)
Discussion started by: cannonfodder
1 Replies
Login or Register to Ask a Question