Skip to content
Snippets Groups Projects
Commit 6298843f authored by rs11g21's avatar rs11g21
Browse files

Able to handle error if xampp is not connected to internet

parent 941b9f94
Branches
No related tags found
No related merge requests found
#! /usr/bin/bash
if [ "$(curl -s -o /dev/null -w "%{http_code}" http://www.google.com/)" -eq "200" ]; then
echo "XAMPP's Apache server is connected to the internet."
awk -F':' '{
if(/BitCoin Value/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO cryptoPrice(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin 24 Hour Low/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO lowPrice(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin 24 Hour High/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO highPrice(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin 24 Hour Open/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO openPrice(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin Market Cap/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO marketCap(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin Change In Value/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO changeInValue(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin Return Percentage/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO returnPercentage(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin Volatility/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO volatility(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin 24 H Transaction Count/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO transactionCount(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}else if(/BitCoin Transaction Fee/){
cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO transactionFee(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
system(cmd)
}
}' < /dev/stdin
else
echo "XAMPP's Apache server is not connected to the internet."
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment