"do shell" vs. Plain old AppleScript nomenclature
"do shell" vs. Plain old AppleScript nomenclature
- Subject: "do shell" vs. Plain old AppleScript nomenclature
- From: "D. Mahaffy" <email@hidden>
- Date: Fri, 23 Jul 2004 11:58:07 -0400
I'm new to this list, and thankful that it exists! There are some
serious experts out there! :-)
That said, I'm looking for an answer/explanation regarding AppleScript
and the "do shell script" command.
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).
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?
Here's a sample of getting time and date:
set theDate to current date
set theTime to (time of theDate)
copy (round (theTime / 3600) rounding down) to theHour
copy (round ((theTime - (theHour * 3600)) / 60) rounding down) to
theMinute
copy ((theTime - (theHour * 3600)) - theMinute * 60) to theSeconds
if theHour < 12 then
copy "AM" to amPM
else
copy "PM" to amPM
if theHour > 12 then
copy theHour - 12 to theHour
end if
end if
if theMinute < 10 then
copy "0" & theMinute to theMinute
end if
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).
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. Oh, and I take away an hour since I am
EDT and the web site is CDT. So that comes in later. But if someone
knows how to do it more easily!
--
Thanks,
Darren
MacSurfer
_______________________________________________
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.