mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
Setting user agent for curl
This commit is contained in:
parent
1d782a374d
commit
f7aaed704c
@ -131,7 +131,7 @@ checkInternet()
|
|||||||
## Grabs the exchange rate and does the math for converting the currency
|
## Grabs the exchange rate and does the math for converting the currency
|
||||||
convertCurrency()
|
convertCurrency()
|
||||||
{
|
{
|
||||||
exchangeRate=$(curl -s "http://api.fixer.io/latest?base=$base&symbols=$exchangeTo" | grep -Eo "[0-9]*[.][0-9]*") > /dev/null
|
exchangeRate=$(curl -Acurl -s "http://api.fixer.io/latest?base=$base&symbols=$exchangeTo" | grep -Eo "[0-9]*[.][0-9]*") > /dev/null
|
||||||
exchangeAmount=$(echo "$exchangeRate * $amount" | bc )
|
exchangeAmount=$(echo "$exchangeRate * $amount" | bc )
|
||||||
echo
|
echo
|
||||||
echo "========================="
|
echo "========================="
|
||||||
@ -150,7 +150,7 @@ update()
|
|||||||
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
||||||
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
||||||
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
||||||
latestVersion=$(curl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
latestVersion=$(curl -Acurl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
||||||
|
|
||||||
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
||||||
echo "Error: update utility has not been configured correctly." >&2
|
echo "Error: update utility has not been configured correctly." >&2
|
||||||
@ -234,6 +234,7 @@ elif [[ $# == "1" ]]; then
|
|||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
echo "Not a valid argument"
|
echo "Not a valid argument"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [[ $# == 3 ]];then
|
elif [[ $# == 3 ]];then
|
||||||
checkBase $1
|
checkBase $1
|
||||||
|
@ -29,7 +29,7 @@ getMovieInfo()
|
|||||||
{
|
{
|
||||||
apiKey=946f500a # try not to abuse this it is a key that came from the ruby-scripts repo I link to.
|
apiKey=946f500a # try not to abuse this it is a key that came from the ruby-scripts repo I link to.
|
||||||
movie="$1+$2+$3+$4+$5+$6+$7+$8+$9" ## format the inputs to use for the api
|
movie="$1+$2+$3+$4+$5+$6+$7+$8+$9" ## format the inputs to use for the api
|
||||||
movieInfo=$(curl -s "http://www.omdbapi.com/?t=$movie&apikey=$apiKey") > /dev/null # query the server and get the JSON response
|
movieInfo=$(curl -Acurl -s "http://www.omdbapi.com/?t=$movie&apikey=$apiKey") > /dev/null # query the server and get the JSON response
|
||||||
checkResponse=$(echo $movieInfo | python -c "import sys, json; print json.load(sys.stdin)['Response']")
|
checkResponse=$(echo $movieInfo | python -c "import sys, json; print json.load(sys.stdin)['Response']")
|
||||||
if [[ $checkResponse == "False" ]];then { echo "No movie found" ; return 1 ;} fi ## check to see if the movie was found
|
if [[ $checkResponse == "False" ]];then { echo "No movie found" ; return 1 ;} fi ## check to see if the movie was found
|
||||||
# The rest of the code is just extrapolating the data with python from the JSON response
|
# The rest of the code is just extrapolating the data with python from the JSON response
|
||||||
@ -70,7 +70,7 @@ update()
|
|||||||
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
||||||
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
||||||
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
||||||
latestVersion=$(curl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
latestVersion=$(curl -Acurl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
||||||
|
|
||||||
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
||||||
echo "Error: update utility has not been configured correctly." >&2
|
echo "Error: update utility has not been configured correctly." >&2
|
||||||
|
@ -26,7 +26,7 @@ checkInternet()
|
|||||||
## JSON response to extrapolate the information for storage
|
## JSON response to extrapolate the information for storage
|
||||||
getStockInformation()
|
getStockInformation()
|
||||||
{
|
{
|
||||||
stockInfo=$(curl -s "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=$1&apikey=KPCCCRJVMOGN9L6T") > /dev/null #grab the JSON response
|
stockInfo=$(curl -Acurl -s "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=$1&apikey=KPCCCRJVMOGN9L6T") > /dev/null #grab the JSON response
|
||||||
export PYTHONIOENCODING=utf8 #necessary for python in some cases
|
export PYTHONIOENCODING=utf8 #necessary for python in some cases
|
||||||
echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']" > /dev/null 2>&1 || { echo "Not a valid stock symbol" ; exit 1; } #checking if we get any information back from the server if not chances are it isnt a valid stock symbol
|
echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']" > /dev/null 2>&1 || { echo "Not a valid stock symbol" ; exit 1; } #checking if we get any information back from the server if not chances are it isnt a valid stock symbol
|
||||||
# The rest of the code is just extrapolating the data with python from the JSON response
|
# The rest of the code is just extrapolating the data with python from the JSON response
|
||||||
@ -69,7 +69,7 @@ printStockInformation()
|
|||||||
## and it will determine the stock symbol for apple is AAPL and move on from there
|
## and it will determine the stock symbol for apple is AAPL and move on from there
|
||||||
getTicker()
|
getTicker()
|
||||||
{
|
{
|
||||||
response=$(curl -s "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=$1+$2+$3+$4+$5+$6+$7+$8+$9®ion=1&lang=en%22") > /dev/null
|
response=$(curl -Acurl -s "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=$1+$2+$3+$4+$5+$6+$7+$8+$9®ion=1&lang=en%22") > /dev/null
|
||||||
symbol=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['ResultSet']['Result'][0]['symbol']") # using python to extrapolate the stock symbol
|
symbol=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['ResultSet']['Result'][0]['symbol']") # using python to extrapolate the stock symbol
|
||||||
unset response #just unsets the entire response after using it since all I need is the stock ticker
|
unset response #just unsets the entire response after using it since all I need is the stock ticker
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ update()
|
|||||||
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
||||||
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
||||||
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
||||||
latestVersion=$(curl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
latestVersion=$(curl -Acurl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
||||||
|
|
||||||
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
||||||
echo "Error: update utility has not been configured correctly." >&2
|
echo "Error: update utility has not been configured correctly." >&2
|
||||||
|
@ -15,21 +15,21 @@ checkCurl()
|
|||||||
|
|
||||||
getIPWeather()
|
getIPWeather()
|
||||||
{
|
{
|
||||||
country=$(curl -s ipinfo.io/country) > /dev/null ## grab the country
|
country=$(curl -Acurl -s ipinfo.io/country) > /dev/null ## grab the country
|
||||||
if [[ $country == "US" ]];then ## if were in the us id rather not use longitude and latitude so the output is nicer
|
if [[ $country == "US" ]];then ## if were in the us id rather not use longitude and latitude so the output is nicer
|
||||||
city=$(curl -s ipinfo.io/city) > /dev/null
|
city=$(curl -Acurl -s ipinfo.io/city) > /dev/null
|
||||||
region=$(curl -s ipinfo.io/region) > /dev/null
|
region=$(curl -Acurl -s ipinfo.io/region) > /dev/null
|
||||||
region=$(echo "$region" | tr -dc '[:upper:]')
|
region=$(echo "$region" | tr -dc '[:upper:]')
|
||||||
curl $locale.wttr.in/$city,$region$1
|
curl -Acurl $locale.wttr.in/$city,$region$1
|
||||||
else ## otherwise we are going to use longitude and latitude
|
else ## otherwise we are going to use longitude and latitude
|
||||||
location=$(curl -s ipinfo.io/loc) > /dev/null
|
location=$(curl -Acurl-s ipinfo.io/loc) > /dev/null
|
||||||
curl $locale.wttr.in/$location$1
|
curl -Acurl $locale.wttr.in/$location$1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocationWeather()
|
getLocationWeather()
|
||||||
{
|
{
|
||||||
curl $locale.wttr.in/$1+$2+$3+$4
|
curl -Acurl $locale.wttr.in/$1+$2+$3+$4
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInternet()
|
checkInternet()
|
||||||
@ -51,7 +51,7 @@ update()
|
|||||||
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite
|
||||||
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein
|
||||||
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one
|
||||||
latestVersion=$(curl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
latestVersion=$(curl -Acurl -s https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
|
||||||
|
|
||||||
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]];then
|
||||||
echo "Error: update utility has not been configured correctly." >&2
|
echo "Error: update utility has not been configured correctly." >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user