Help with shell script to test proxy

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I installed an HTTPIE tool on my Linux server to test our proxy for response from sites like google.com and i'm trying to write a script to test if our traffic getting through the proxy or not
For example: I want the script to run the command below and if i get the results including the 200 OK then traffic went through fine and if i don't get response then i want the script to send an email to let me know the command did not return results.



Below is the example and then the first part of the script i wrote and i need help with the rest of the script



# http --proxy=http:http://my_proxy:3128 head www.google.com

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 4622
Content-Type: text/html; charset=ISO-8859-1
Date: Sat, 28 Apr 2018 01:40:13 GMT
Expires: -1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Proxy-Connection: keep-alive
Server: gws
Set-Cookie: 1P_JAR=2018-04-28-01; expires=Mon, 28-May-2018 01:40:13 GMT; path=/; domain=.google.com
Set-Cookie: NID=129=eWFNZlP7mCtJ_zVH7sa6kxTOc9ebMpwLMgUSVnfMA1_bJM2UFfZwly9-BqDSPFI2EaY45t7GhTAte-w783Od3JZ5MGcqmjxT86h8yKdAK1t1qlCm9oexkaYRFgRp64MK; expires=Sun, 28-Oct-2018 01:40:13 GMT; path=/; domain=.google.com; HttpOnly
Via: 1.1 isdsecwsandc2.tch.harvard.edu:3128 (Cisco-WSA/10.5.2-042)
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block


So i just want to write a script to run the command above against each proxy IP address and if i get 200 OK back then go to the next one and if it times out then send me an email to let me know



The script is here:



#!/bin/bash

proxy_targets="http://10.5.5.5:3128 http://10.5.5.6:3128 http://10.5.5.7:3128"

failed_hosts=""

for i in $proxy_targets
do
http --proxy=http:$i head www.google.com > /dev/null


ANy help completing the script would be greatly appreciated







share|improve this question





















  • man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
    – ivanivan
    Apr 28 at 2:34










  • I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
    – Katkota
    Apr 28 at 2:43










  • wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
    – ivanivan
    Apr 28 at 3:11










  • Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
    – Romeo Ninov
    Apr 28 at 9:04










  • Any help folks completing the script i started already or even providing a different script to do it?
    – Katkota
    May 5 at 2:59














up vote
0
down vote

favorite












I installed an HTTPIE tool on my Linux server to test our proxy for response from sites like google.com and i'm trying to write a script to test if our traffic getting through the proxy or not
For example: I want the script to run the command below and if i get the results including the 200 OK then traffic went through fine and if i don't get response then i want the script to send an email to let me know the command did not return results.



Below is the example and then the first part of the script i wrote and i need help with the rest of the script



# http --proxy=http:http://my_proxy:3128 head www.google.com

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 4622
Content-Type: text/html; charset=ISO-8859-1
Date: Sat, 28 Apr 2018 01:40:13 GMT
Expires: -1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Proxy-Connection: keep-alive
Server: gws
Set-Cookie: 1P_JAR=2018-04-28-01; expires=Mon, 28-May-2018 01:40:13 GMT; path=/; domain=.google.com
Set-Cookie: NID=129=eWFNZlP7mCtJ_zVH7sa6kxTOc9ebMpwLMgUSVnfMA1_bJM2UFfZwly9-BqDSPFI2EaY45t7GhTAte-w783Od3JZ5MGcqmjxT86h8yKdAK1t1qlCm9oexkaYRFgRp64MK; expires=Sun, 28-Oct-2018 01:40:13 GMT; path=/; domain=.google.com; HttpOnly
Via: 1.1 isdsecwsandc2.tch.harvard.edu:3128 (Cisco-WSA/10.5.2-042)
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block


So i just want to write a script to run the command above against each proxy IP address and if i get 200 OK back then go to the next one and if it times out then send me an email to let me know



The script is here:



#!/bin/bash

proxy_targets="http://10.5.5.5:3128 http://10.5.5.6:3128 http://10.5.5.7:3128"

failed_hosts=""

for i in $proxy_targets
do
http --proxy=http:$i head www.google.com > /dev/null


ANy help completing the script would be greatly appreciated







share|improve this question





















  • man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
    – ivanivan
    Apr 28 at 2:34










  • I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
    – Katkota
    Apr 28 at 2:43










  • wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
    – ivanivan
    Apr 28 at 3:11










  • Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
    – Romeo Ninov
    Apr 28 at 9:04










  • Any help folks completing the script i started already or even providing a different script to do it?
    – Katkota
    May 5 at 2:59












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I installed an HTTPIE tool on my Linux server to test our proxy for response from sites like google.com and i'm trying to write a script to test if our traffic getting through the proxy or not
For example: I want the script to run the command below and if i get the results including the 200 OK then traffic went through fine and if i don't get response then i want the script to send an email to let me know the command did not return results.



Below is the example and then the first part of the script i wrote and i need help with the rest of the script



# http --proxy=http:http://my_proxy:3128 head www.google.com

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 4622
Content-Type: text/html; charset=ISO-8859-1
Date: Sat, 28 Apr 2018 01:40:13 GMT
Expires: -1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Proxy-Connection: keep-alive
Server: gws
Set-Cookie: 1P_JAR=2018-04-28-01; expires=Mon, 28-May-2018 01:40:13 GMT; path=/; domain=.google.com
Set-Cookie: NID=129=eWFNZlP7mCtJ_zVH7sa6kxTOc9ebMpwLMgUSVnfMA1_bJM2UFfZwly9-BqDSPFI2EaY45t7GhTAte-w783Od3JZ5MGcqmjxT86h8yKdAK1t1qlCm9oexkaYRFgRp64MK; expires=Sun, 28-Oct-2018 01:40:13 GMT; path=/; domain=.google.com; HttpOnly
Via: 1.1 isdsecwsandc2.tch.harvard.edu:3128 (Cisco-WSA/10.5.2-042)
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block


So i just want to write a script to run the command above against each proxy IP address and if i get 200 OK back then go to the next one and if it times out then send me an email to let me know



The script is here:



#!/bin/bash

proxy_targets="http://10.5.5.5:3128 http://10.5.5.6:3128 http://10.5.5.7:3128"

failed_hosts=""

for i in $proxy_targets
do
http --proxy=http:$i head www.google.com > /dev/null


ANy help completing the script would be greatly appreciated







share|improve this question













I installed an HTTPIE tool on my Linux server to test our proxy for response from sites like google.com and i'm trying to write a script to test if our traffic getting through the proxy or not
For example: I want the script to run the command below and if i get the results including the 200 OK then traffic went through fine and if i don't get response then i want the script to send an email to let me know the command did not return results.



Below is the example and then the first part of the script i wrote and i need help with the rest of the script



# http --proxy=http:http://my_proxy:3128 head www.google.com

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 4622
Content-Type: text/html; charset=ISO-8859-1
Date: Sat, 28 Apr 2018 01:40:13 GMT
Expires: -1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Proxy-Connection: keep-alive
Server: gws
Set-Cookie: 1P_JAR=2018-04-28-01; expires=Mon, 28-May-2018 01:40:13 GMT; path=/; domain=.google.com
Set-Cookie: NID=129=eWFNZlP7mCtJ_zVH7sa6kxTOc9ebMpwLMgUSVnfMA1_bJM2UFfZwly9-BqDSPFI2EaY45t7GhTAte-w783Od3JZ5MGcqmjxT86h8yKdAK1t1qlCm9oexkaYRFgRp64MK; expires=Sun, 28-Oct-2018 01:40:13 GMT; path=/; domain=.google.com; HttpOnly
Via: 1.1 isdsecwsandc2.tch.harvard.edu:3128 (Cisco-WSA/10.5.2-042)
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block


So i just want to write a script to run the command above against each proxy IP address and if i get 200 OK back then go to the next one and if it times out then send me an email to let me know



The script is here:



#!/bin/bash

proxy_targets="http://10.5.5.5:3128 http://10.5.5.6:3128 http://10.5.5.7:3128"

failed_hosts=""

for i in $proxy_targets
do
http --proxy=http:$i head www.google.com > /dev/null


ANy help completing the script would be greatly appreciated









share|improve this question












share|improve this question




share|improve this question








edited Apr 28 at 3:01
























asked Apr 28 at 2:15









Katkota

384




384











  • man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
    – ivanivan
    Apr 28 at 2:34










  • I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
    – Katkota
    Apr 28 at 2:43










  • wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
    – ivanivan
    Apr 28 at 3:11










  • Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
    – Romeo Ninov
    Apr 28 at 9:04










  • Any help folks completing the script i started already or even providing a different script to do it?
    – Katkota
    May 5 at 2:59
















  • man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
    – ivanivan
    Apr 28 at 2:34










  • I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
    – Katkota
    Apr 28 at 2:43










  • wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
    – ivanivan
    Apr 28 at 3:11










  • Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
    – Romeo Ninov
    Apr 28 at 9:04










  • Any help folks completing the script i started already or even providing a different script to do it?
    – Katkota
    May 5 at 2:59















man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
– ivanivan
Apr 28 at 2:34




man curl and man wget - both have multiple proxy options (how to auth, etc) and which you'll need depends exactly on your setup.
– ivanivan
Apr 28 at 2:34












I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
– Katkota
Apr 28 at 2:43




I just want to write a script that would run the command against each proxy IP and if i get 200 OK back then go to the next one and if it times out, then send me an email
– Katkota
Apr 28 at 2:43












wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
– ivanivan
Apr 28 at 3:11




wget can be redirected to /dev/null for all output, then check the exit status with $? being equal to 0 then there are no errors. I don't have a proxy to test against.
– ivanivan
Apr 28 at 3:11












Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
– Romeo Ninov
Apr 28 at 9:04




Have you try to export http_proxy (export http_proxy=10.5.5.5:3128) variable and test with wget?
– Romeo Ninov
Apr 28 at 9:04












Any help folks completing the script i started already or even providing a different script to do it?
– Katkota
May 5 at 2:59




Any help folks completing the script i started already or even providing a different script to do it?
– Katkota
May 5 at 2:59















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f440524%2fhelp-with-shell-script-to-test-proxy%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f440524%2fhelp-with-shell-script-to-test-proxy%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Christian Cage

How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?