• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using grep in a do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: using grep in a do shell script
      • From: Graham Anderson <email@hidden>
References: 
 >Re: using grep in a do shell script (From: Gnarlodious <email@hidden>)
 >Re: using grep in a do shell script (From: Graham Anderson <email@hidden>)

  • Prev by Date: Re: using grep in a do shell script
  • Next by Date: Re: using grep in a do shell script
  • Previous by thread: Re: using grep in a do shell script
  • Next by thread: Re: using grep in a do shell script
  • Index(es):
    • Date
    • Thread