Loop to curl multiple ips to ipinfo.io


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loop to curl multiple ips to ipinfo.io
# 1  
Old 11-02-2016
Loop to curl multiple ips to ipinfo.io

I am rather new to shell scripting and currently taking a linux course.
Im having some troubles writing a loop to curl multiple ips in mutiple access logs to the site ipinfo.io and push the output to a text file for easy viewing and removing duplicates.

So far i have these simple lines

Code:
cat /home/access_log | awk '{ print $1 }' | sort | uniq -c | sort -n

- Brings up a sorted list of ips in this access log

Code:
xzcat /home/access_log-20160917.xz | awk '{ print $1 }' | sort | uniq -c | sort -n

xzcat /home/access_log-20161005.xz | awk '{ print $1 }' | sort | uniq -c | sort -n

and this is my sample curl command of one single ip address

Code:
curl --header "X-Forwarded-For: 137.226.113.7" ipinfoio

(cant post urls yet Smilie )

Now this is where i get stuck......i dont know where to begin when it comes to combining all the logs together then using cat to put them all into one single file. I then want to create a loop that takes all those ips and curls them to ipinfo and then redirecting the output to a text file. Please and thank you for the help. Sorry for the ignorance.



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 11-02-2016 at 03:58 PM.. Reason: Added CODE tags.
# 2  
Old 11-02-2016
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check status of long running multiple curl commands in shell script

I am working on script. it reads a file which contains multiple lines Ex; curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=1 curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=2 curl --write-out %{http_code} --silent ... (2 Replies)
Discussion started by: oraclermanpt
2 Replies

2. Shell Programming and Scripting

HELP - loop a curl command with different variables from input file

Hi guys! Kind of new to bash scripting and now I'm stuck. I need to curl with these variables: "{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }" and my input_file.txt contains server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies

3. Shell Programming and Scripting

Curl - upload multiple attachment arrays to server webpage

The html page of the form data is as below <form name="uploadform" id="uploadform" action="htmlupload.php" enctype="multipart/form-data" method="post"> <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center"> <tr> <td class="tcat"> Upload Files ... (0 Replies)
Discussion started by: jaango123
0 Replies

4. Homework & Coursework Questions

Curl Loop help

1. The problem statement, all variables and given/known data: Here is my assignment. Parse the /home/access_log and /home/access_.xz files Create a sorted list of ip address with no duplicates Pass each ip address to ipinfo.io with curl Create a logfile that has the ip address,lat,long Save... (1 Reply)
Discussion started by: kjcraig77
1 Replies

5. Shell Programming and Scripting

Curl command to download multiple files with a file prefix

I am using the below curl command to download a single file from client server and it is working as expected curl --ftp-ssl -k -u ${USER}:${PASSWD} ftp://${HOST}:${PORT}/path/to/${FILE} --output ${DEST}/${FILE} let say the client has 3 files hellofile.101, hellofile.102, hellofile.103 and I... (3 Replies)
Discussion started by: r@v!7*7@
3 Replies

6. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

7. Shell Programming and Scripting

Perl : ping for multiple IPs not working

I have written perl ping program to ping list of IPs one by one and print the status.But each and every time it is showing the status as Pass for all IPs even though the IP is wrong. multipleip.pl use Net::Ping; $p = Net::Ping->new(); $ifile="inventory.txt"; ... (2 Replies)
Discussion started by: scriptscript
2 Replies

8. Red Hat

Posting Multiple Files using cURL

Hi, I am currently in the process of creating a script that will use cURL to HTTP POST the contents of a file on the server. I am able to run the command; curl -d @/path/to/file/filename.dat "https://posting.server.com/test.aspx"to post a single file and this works as expected. The... (4 Replies)
Discussion started by: MarkPaxo
4 Replies

9. UNIX for Dummies Questions & Answers

routing multiple IPs

hi guys This is suse 11 sp1 I have a Server that has 4 NICs, I've created 2 bonds bond0(eth0-eth1) - 10.10.10.2 bond1(eth2-eth3) - 10.10.10.3 Each bound goes to a Storage Device which is directly connected so bond0 goes to Storage_Controller_1 and 2 like this Server_bond0 <-------->... (2 Replies)
Discussion started by: karlochacon
2 Replies

10. UNIX for Dummies Questions & Answers

How to assign multiple IPs to Aggregated interface in Solaris 10?

I have 2 physical interfaces (bnx0 and bnx1) aggregated into aggr1. I need to assign second IP, and normally I know how to do it to physical interface (i.e. bnx0:1) however same trick (aggr1:1) is not working. Is there any way to do it? (0 Replies)
Discussion started by: bratan
0 Replies
Login or Register to Ask a Question