Register
It is currently Wed Jul 23, 2014 9:49 pm

extract text using sed


All times are UTC - 6 hours


Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2
Author Message
 PostPosted: Fri Feb 18, 2011 1:24 pm   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
it's not having any of it still no output i'm going have to think of another way to do it.

update: ok found the software gpsread which outputs

Code:
GPSD,O=GGA 1298057727.000 0.005 11.111111 -1.111111 88.40 5.40 3.40 ? ? 0.000 ? 27.00 ? 3
GPSD,O=GSA 1298057727.000 0.005 11.111111 -1.111111 88.40 5.40 3.40 ? ? 0.000 ? 27.00 ? 3
GPSD,O=RMC 1298057727.000 0.005 11.111111 -1.111111 88.40 5.40 3.40 48.2700 0.350 0.000 ? 27.00 ? 3


so from that I would like just the 11.111111 -1.111111 from GPSD,O=RMC which would give me long/lat

from that i'd like to get the output of

http://maps.google.com/maps/maps?q=11.1 ... output=xml

then 'hopefully' the last bit of code you did should work.


Top
 Profile  
 PostPosted: Mon Feb 21, 2011 4:50 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
I basically understand how to sed text but how would I do it in this situation?


Top
 Profile  
 PostPosted: Thu Feb 24, 2011 5:28 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
nearly cracked it, i've managed to get the url I want stored on its own in a text file called gps.dat

http://maps.google.com/maps/maps?q=00.0000,-0.00000

The last thing I need to do is curl that url in bash

something like

curl -s gps.dat | sed -n 's/.*<LocalityName>\(.*\)<\/LocalityName>.*/\1/p'

any ideas?

ok got bit further

Code:
read line1 < gps.dat

curl -s "$line1" | sed -n 's/.*<LocalityName>\(.*\)<\/LocalityName>.*/\1/p'


The script now outputs my 'locality' but what I need it to do is output it on my LCD display.

I already have the date displayed on my display using

Code:
/lcd "$(date "+%d/%m/%y    %T")"


but how do I get 'locality' to work?

ie
Code:
/lcd "curl -s "$line1" | sed -n 's/.*<LocalityName>\(.*\)<\/LocalityName>.*/\1/p'"


Top
 Profile  
 PostPosted: Thu Feb 24, 2011 9:10 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hello BrianUK!

Glad you're getting closer!

Do you see the difference between your date example and your second example with your curl line?

Code:
#date example:
/lcd "$(date "+%d/%m/%y    %T")"

#curl example:
/lcd "curl -s "$line1" | sed -n 's/.*<LocalityName>\(.*\)<\/LocalityName>.*/\1/p'"


The difference is that in your working 'date' example, you're executing the date command inside the parentheses of the $() notation.
In your non-working 'curl' example, you're not _executing_ curl. You're essentially telling it to _display_ that curl command, which might not have the results that you expect.

Try enclosing it in $() like your date example:
Code:
/lcd "$(curl -s "$line1" | sed -n 's/.*<LocalityName>\(.*\)<\/LocalityName>.*/\1/p')"


I hope this helps!
-J


Top
 Profile YIM  
 PostPosted: Thu Feb 24, 2011 9:23 am   

Joined: Fri May 16, 2008 4:58 am
Posts: 94
Top job jeo all working now, many many thanks for all your help


Top
 Profile  
 PostPosted: Thu Feb 24, 2011 9:32 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Glad we could be of service. Good luck!


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP