Re: using grep in a do shell script
Re: using grep in a do shell script
- Subject: Re: using grep in a do shell script
- From: Roger Howard <email@hidden>
- Date: Mon, 24 Jan 2005 16:16:45 -0800
On Jan 24, 2005, at 4:01 PM, Graham Anderson wrote:
this does not quite work...but is it a bit closer ?
many thanks
set my_path to (path to preferences) & "Fonovisa.xml" as string
set thepath to POSIX path of my_path
loadTextFile(thepath)
on loadTextFile(thepath)
try
set thestring to ""
set theScript to ("cat " & "'" & thepath & "'")
set thestring to do shell script theScript
--return thestring
set gimme to do shell script "echo " & thestring & " | tr '\\r'
'\\n' | sed -n '/<ram>/{s/.*<ram>\\(.*\\)<\\/ram>.*/\\1/p;}' "
return gimme
on error err
log ("Cat text file error: " & err)
end try
end loadTextFile
Grep... no fun to me :)
Why not use tools that understand XML if you're trying to parse XML?
Admittedly you didn't post an example of the whole XML doc... but
here's a simple example using LateNightSW's XML Tools for parsing a
VERY simple XML doc.
Put the following into a file and save it:
<ram>512</ram>
Now install XMLTools and run this from your script editor:
item 1 of XML contents of (parse XML (choose file))
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden