Re: a way to catch an error in do shell script CDM password
Re: a way to catch an error in do shell script CDM password
- Subject: Re: a way to catch an error in do shell script CDM password
- From: "Koshiro MITSUYA" <email@hidden>
- Date: Thu, 19 Jun 2008 16:09:45 +0900
Dear Luther
Thank you very much for your information.
It helps me to make the algorithm below!
(1) obtain the password
(2) check the password
if the password is correct:
(3) run the command with administrator privilege
if the password is incorrect:
(4) exit
This is exactly what I want to do :)
thanks again,
Koshiro
On Mon, Jun 16, 2008 at 4:41 AM, Luther Fuller <email@hidden> wrote:
> On Jun 15, 2008, at 12:04 PM, Koshiro MITSUYA wrote:
>>
>> I am trying to get the error in "do shell script CMD password with
>> adminstrator privileges" when an incorrent userpassword was given. The
>> code is like below.
>>
>> try
>> do shell script "ls -l /private/root/" password userpassword with
>> administrator privileges
>> on error
>> display dialog "Sorry, the password entered was not correct."
>> end try
>>
>> However, it automatically runs the SecurityAgent to ask the correct
>> password. Is there any way to prevent to run SecurityAgent and
>> catch the error instead?
>
>
>
> I had a similar problem about a month ago ("When is a disk image file
> encrypted?").
> My solution was this handler ...
>
> on isEncrypted(imageAlias)
> set imagePath to quoted form of (POSIX path of imageAlias)
> try
> do shell script "echo -n '' | hdiutil imageinfo -stdinpass "
> & imagePath
> on error
> return true
> end try
> return false
> end isEncrypted
>
> The echo -n '' puts the empty string into stdin, then the '-stdinpass'
> option tells 'hdiutil' to get the password from stdin. This is what avoids
> the SecurityAgent password dialog. The empty string isn't the password for
> anything, so if the disk image file 'imageAlias' is encrypted, true is
> returned.
>
> Your problem, now, is that the 'ls' command does not have a password option
> of any kind. In fact, I wonder if the 'do shell script' is correctly formed.
>
>
_______________________________________________
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