Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My file like this with some number or id

 404000847307897
 404000857827460
 404001044194601
 404000835511595
 404000338418501
 404000338654003
 404000290144612
 404000344175621
 404000290144612
 404000844713523

this my url

 url= http://203.90.117.109/wds_cdma/wds.aspx?min= 

now by using this url get the response from url and download output of the url. not the code.

example take the url and add the min = file id number at end of the url.

(http://203.90.117.109/wds_cdma/wds.aspx?min=404000847307897)
(http://203.90.117.109/wds_cdma/wds.aspx?min=404000857827460)

this url hit the server get the response of the url ouput below

 404000847307897|-101| Requested MIN not found.
 404000857827460|9225534526|2|Prepaid|2 

finally this output store in one file.

can you do this curl with awk or wget?

share|improve this question
add comment

2 Answers

I can't comment yet to ask for more details on your question so I'll guess : you have a file containing a list of numbers, you want to query an URL using each of these numbers as parameters and store the results in one file.

Using wget in a shell script :

#!/bin/sh
PARAMETER_FILE="/path/to/parameter/file"
URL="http://203.90.117.109/wds_cdma/wds.aspx?min="
OUTPUT_FILE="/path/to/output/file"

IFS="
"

for param in $(cat "$PARAMETER_FILE")
do
  wget "${URL}${param}" >> "$OUTPUT_FILE"
done
share|improve this answer
    
it is possible run in gnuwin32. how to run this? i am new to shell script? please tell me @ louis carrese –  ganik Jul 31 '13 at 5:17
    
I did not know about gnuwin32, but I guess you could if you installed the wget package. However, you might have to do it with a .bat script so the "for" loop would not be the same. If you have to do this in Windows, I suggest you try installing Cygwin. It will allow you to run true shell scripts. –  Louis Carrese Jul 31 '13 at 11:06
add comment

Assuming the list of file IDs is in a file called file_ids.txt.

for i in $(cat file_ids.txt); do 
   curl http://203.90.117.109/wds_cdma/wds.aspx?min=$i -O -s >> output.txt;
done

The above will create a bunch of commands like this:

curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000847307897 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000857827460 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404001044194601 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000835511595 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000338418501 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000338654003 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000290144612 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000344175621 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000290144612 -O -s >> output.txt
curl http://203.90.117.109/wds_cdma/wds.aspx?min=404000844713523 -O -s >> output.txt

The above loops through the list of file IDs and runs the curl command appending the output from the HTTP GET to the file output.txt. The operator >> takes the output from the curl commands and appends it to the file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.