Re: Simple apple script - Beginner Problem
Re: Simple apple script - Beginner Problem
- Subject: Re: Simple apple script - Beginner Problem
- From: Doug McNutt <email@hidden>
- Date: Tue, 14 Jul 2009 05:45:54 -0600
At 11:15 +0100 7/14/09, James Bensley wrote:
>I'm an apple script beginner and I can't work out my script isn't
>working; I have written a wee line of shell script which I want to run
>from an apple script, this snippet is broken. It displays the UNC path
>of a users home folder stored in Active Directory, it just prompts the
>user for their username then it looks up their unc location:
>
>property user_name : ""
>if user_name is "" then
> set dialog_1 to display dialog "Please enter your username" default answer ""
> set the user_name to the text returned of dialog_1
>end if
>
>set UNC to (do shell script "dscl localhost read /Active Directory/All
>Domains/Users/" & user_name & " homeDirectory | awk
>'BEGIN{FS=\":\"};{print $3}'")
>display dialog UNC
>
>
>Pretty simple really. There are two things to note here; The spaces in
>"Active Directory/All Domains" did have an escaping \ in them when I
>wrote the line in a shell script but the apple script editor doesn't
>like them? Also the awk bit didn't have the escaping \'s on the
>command line button apple script editor wants them added it?
Quoting special characters - such as blanks - is a pain because Applescript and bash use the same escape character and you need to escape the escapes to get to the shell. It all results in lots of blackslash characters. Even simple quote marks and apostrophes cause problems.
"quoted form of" is available and there is a tech note on it somewhere.
try replacing each item headed for the shell in the do shell script line with quoted form of (the item as you have it.)
And it's not "quoted form of" or quoted_form_of. Us old fashioned UNIX types will never get used to spaces in function names and commands.
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden