Re: Do Shell Script returns empty string but works in Terminal
Re: Do Shell Script returns empty string but works in Terminal
- Subject: Re: Do Shell Script returns empty string but works in Terminal
- From: Andrew Oliver <email@hidden>
- Date: Thu, 03 Aug 2017 06:45:20 +0100
If it is using StdEer instead of StdOut you can use do shell script - you just
need to capture stderr in the output.
This is easiest done by appending '2>&1' to the end of the 'do shell script'
command, which tells he shel to output stderr to the same place as stdout,
hence passing it back to your AppleScript.
Andrew
Sent from my iPhone
> On Aug 3, 2017, at 6:03 AM, Shane Stanley <email@hidden> wrote:
>
>> On 3 Aug 2017, at 12:47 pm, Bob Stern <email@hidden> wrote:
>>
>> The “do shell script” AppleScript does cause the client/server application
>> to perform the specified command except that it fails to return a result.
>
> The problem appears to be that the binary is returning the result you want to
> standardErr, not standardOut. 'do shell script' ignores standardErr unless
> the binary's termination status is other than 0, in which case it uses it for
> the error message.
>
> You can work around it by using AppleScriptObjC and NSTask instead of 'do
> shell script', as long as it never returns very large amounts of data.
>
> It probably wouldn't hurt to ask the developers why they're doing it this
> way...
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
>
>
> _______________________________________________
> 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
_______________________________________________
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