Author

Topic: Help me with a simple Linux script (Read 830 times)

newbie
Activity: 42
Merit: 0
August 03, 2011, 05:46:09 PM
#4
And if you prefer one-liners
Code:
curl "http://www.mywebsite.com/update_temp.php?rig=1`DISPLAY=:0;aticonfig --adapter=all --odgt | awk 'BEGIN {counter=1} /Temperature/ {printf "&temp"counter++"="$5}'`"

At first I thought maybe sed could do this, but after 30min of trying sed, and spamming the google search, I gave up and gave awk a shot and was surprised at how easy and powerful the syntax was.
newbie
Activity: 55
Merit: 0
August 03, 2011, 09:42:19 AM
#3
Thanks, works like a gem!
newbie
Activity: 42
Merit: 0
August 02, 2011, 03:17:50 PM
#2
curl
sorry, came back and saw that you just didn't want the GET solved, you wanted some chopping as well.

Quote
#!/bin/bash
Counter="0"
URL="http://www.mywebsite.com/update_temp.php?rig=1"

for Temp in `export DISPLAY=:0;aticonfig --adapter=all --odgt | grep -o '...\...' | sed -e 's/^[ \t]*//'`
  do
    Counter="$(($Counter+1))"
    URL="${URL}&temp$Counter=$Temp"
  done
curl "$URL"

Working as intended?
newbie
Activity: 55
Merit: 0
August 02, 2011, 02:53:30 PM
#1
Here's what I'm trying to do, I am trying to extract the temperature from every card and send them to my web server as a GET request so I can update a database on my web server.

What I have so far:

Code:
export DISPLAY=:0;aticonfig --adapter=all --odgt | grep -o '...\...' | sed -e 's/^[ \t]*//'

This gives me:

Code:
91.00
91.50
91.00
82.50

How do I chop this with shell scripting and send it as part of a GET request as such:

Code:
GET http://www.mywebsite.com/update_temp.php?rig=1&temp1=91.00&temp2=91.50&temp3=91.00&temp4=82.50

Thanks Gurus!
Jump to: