• 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: Native AS or grep via do shell script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Native AS or grep via do shell script?


  • Subject: Re: Native AS or grep via do shell script?
  • From: Eric Geoffroy <email@hidden>
  • Date: Wed, 27 Oct 2004 12:19:57 -0700

Hi,

I have at least two posts on Apple Discussions where I asked a question and then answered it myself the next day. Oh well. It's part of the learning process I guess.

I've had to echo back all my shell commands like sort -u, ,uniq, and grep. Thanks for replying to the list because your grepPattern gave me a great idea to use on other number strings just like that. I wonder if it will catch one per line (record) or every one that appears in a line. I'll have to experiment.

Thanks,
Eric

On Oct 27, 2004, at 3:00 AM, Jakob Peterhänsel wrote:

Hi all,

Guess I have to answer this myself...

If the text in the emails had been consistent, AS could have done the
job, but it's not stable enough.
Grep to the rescue.

set grepPattern to "[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"

In order to get the stdout from the CLI, it seems we have to use 'echo',
and then pipe the variable data to grep:


set theDates to (do shell script "echo " & quoted form of theBody & " |
grep -e '" & grepPattern & "'") as text

Consider the mailbody below, it will give us back a two-line reply:
-> "02-10-2004 00:00
02-10-2004 06:00"

For some reason, we can't do:

set myDate to "02-10-2004 00:00" as date

But, this seems to work:
set dd to "02-10-2004 00:00"
set myDate to (date dd)


Now, if only the CLI grep was as flexible as the one in BBEdit... :-/



____________________________________________
Jakob Peterhänsel
Network Consultant
Tel: +45 7022 1014
Fax: +45 7022 1013
Mob: +45 22 68 49 61
email@hidden
www.NetPoint.com


On 25. okt 2004, at 15:11, Jakob Peterhänsel wrote:


Hi All, I have some messages coming in via Mail.app that I woudl like
to process, parse and create entries in iCal for.
As they are not that structured, I would like to ask how the gurus on
this list would handle this: Native in AppleScript, or via grep/do
shell script?

The messages body looks something like this:
----------------------------------------------------------------------
-----------------------------------
For at sikre stabil liniedrift, foretager vi med kort varsel en
kritisk opgradering i følgende område:

Hele landet

Der vil blive foretaget en kritisk software opgradering i tidrummet
mellem 0:00 og 6:00

I perioden:
02-10-2004 00:00
til
02-10-2004 06:00

Følgende platforme vil blive berørt:
VPN, Medarbejderbredbånd, Data/Internet

Vi beklager de gener, dette måtte medføre.

----------------------------------------------------------------------
-----------------------------------

I would like to get the two dates, if they exists, the line with "Hele
Landet" and the line starting with "VPN, Medarbejderbredbånd...."

Any clues?


____________________________________________ Jakob Peterhänsel Network Consultant Tel: +45 7022 1014 Fax: +45 7022 1013 Mob: +45 22 68 49 61 email@hidden www.NetPoint.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
e.dk

This email sent to email@hidden

<ATT1239799.txt>

_______________________________________________ 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
References: 
 >Re: Native AS or grep via do shell script? (From: Jakob Peterhänsel <email@hidden>)

  • Prev by Date: Re: Setting the default signature in Entourage
  • Next by Date: Re: Native AS or grep via do shell script?
  • Previous by thread: Re: Native AS or grep via do shell script?
  • Next by thread: Re: Native AS or grep via do shell script?
  • Index(es):
    • Date
    • Thread