Bitcoin Forum
May 14, 2024, 08:46:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help me with a simple Linux script  (Read 795 times)
sabe (OP)
Newbie
*
Offline Offline

Activity: 55
Merit: 0


View Profile
August 02, 2011, 07: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!
1715676369
Hero Member
*
Offline Offline

Posts: 1715676369

View Profile Personal Message (Offline)

Ignore
1715676369
Reply with quote  #2

1715676369
Report to moderator
1715676369
Hero Member
*
Offline Offline

Posts: 1715676369

View Profile Personal Message (Offline)

Ignore
1715676369
Reply with quote  #2

1715676369
Report to moderator
1715676369
Hero Member
*
Offline Offline

Posts: 1715676369

View Profile Personal Message (Offline)

Ignore
1715676369
Reply with quote  #2

1715676369
Report to moderator
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715676369
Hero Member
*
Offline Offline

Posts: 1715676369

View Profile Personal Message (Offline)

Ignore
1715676369
Reply with quote  #2

1715676369
Report to moderator
cirz8
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
August 02, 2011, 08:17:50 PM
Last edit: August 02, 2011, 08:58:25 PM by cirz8
 #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?
sabe (OP)
Newbie
*
Offline Offline

Activity: 55
Merit: 0


View Profile
August 03, 2011, 02:42:19 PM
 #3

Thanks, works like a gem!
cirz8
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
August 03, 2011, 10: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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!