Improving checkInternet to support proxies
This commit is contained in:
parent
4b0c2da14c
commit
29ab12cd0e
|
@ -38,13 +38,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
@ -26,13 +26,7 @@ getConfiguredClient()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
|
|
|
@ -129,13 +129,7 @@ checkAmount()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## Grabs the exchange rate and does the math for converting the currency
|
||||
|
|
|
@ -38,13 +38,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
8
geo/geo
8
geo/geo
|
@ -177,13 +177,7 @@ update()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,13 +55,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## This function grabs information about a movie and using python parses the
|
||||
|
|
|
@ -84,13 +84,7 @@ makeMultiLineQr()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connect" >&2
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
usage()
|
||||
|
|
|
@ -55,13 +55,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
@ -8,16 +8,16 @@ configuredPython=""
|
|||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null ; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null ; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null ; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
if command -v curl &>/dev/null ; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null ; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null ; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## This function grabs information about a stock and using python parses the
|
||||
|
|
|
@ -58,13 +58,7 @@ httpGet()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
@ -55,13 +55,7 @@ getLocationWeather()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
|
|
|
@ -26,13 +26,7 @@ getConfiguredClient()
|
|||
|
||||
checkInternet()
|
||||
{
|
||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||
if [ $? -eq 0 ]; then #check if the output is 0, if so no errors have occured and we have connected to google successfully
|
||||
return 0
|
||||
else
|
||||
echo "Error: no active internet connection" >&2 #sent to stderr
|
||||
return 1
|
||||
fi
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
|
|
Loading…
Reference in New Issue