Re: "do shell" vs. Plain old AppleScript nomenclature
Re: "do shell" vs. Plain old AppleScript nomenclature
- Subject: Re: "do shell" vs. Plain old AppleScript nomenclature
- From: LuKreme <email@hidden>
- Date: Fri, 23 Jul 2004 20:15:46 -0600
On 23 Jul 2004, at 09:58, D. Mahaffy wrote:
>
Simply, why would I want to use "do shell script" as opposed to parsing
>
out my request using AppleScript "lingo"? (Pardon my nomenclature, I'm
>
a "novice" when it comes to scripting).
For the same reason you might want to use a hex wrench on a screw
instead of a flathead. Right tool for the job and all that.
>
I've got a script that parses out the date and time that is "long" for
>
what I'm needing (doing time-zone compensation, etc.). It seems that
>
the main (positive) thing with shell scripting via A/S is brevity.
>
>
But another poster (Andrew Oliver) said, essentially, why spawn extra
>
shell process when you don't need to?
Depends on if spawning the shell script will save you time and make
your script faster.
>
Here's a sample of getting time and date:
-- %I is 0 padded 12 hour clock, %M is minutes and %p is AM/PM
set HourMin to do shell script "date +%I%M%p"
set theHour to text 1 through 2 of HourMin as string
set theMinute to text 3 through 4 of HourMin as string
set amPM to text 5 through 6 of HourMin as string
-- We use the 0 pad for parsing purpses, but we don't want the 0
if first character of theHour is equal to "0" then
set theHour to character 2 of theHour
end if
set theTime to (theHour & ":" & theMinute & " " & amPM) as text
display dialog theTime
>
With "do shell script" I gather that some of this can be shortened
>
using the % commands, yes? Is there a reference of the commands for
>
time/date - and HOW to write them? I find the script library commands,
>
while useful for finding commands, is not useful for how to properly
>
write them out (for newbies, at least).
`man date` will lead to `man strftime`
>
Did find shell references on the web, but experimented with and without
>
success. Date parsing was somewhat successful, but getting a time
>
stamp of say: 4:23 PM was not.
date "+%l:%M %p"
--
Behind every great man there's a woman with a vibrator -- Hawkeye Pierce
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.