Page 1 of 1

shutdown applescript wrong

Posted: Mon Feb 01, 2016 11:44 am
by AlessioForconi
Hi,

why do you think this works

Code: Select all

do "tell application" && quote & "Finder" & quote && "to shut down" as AppleScript
and this not?

Code: Select all

do "tell application" && quote & "Finder" & quote && "to shut down -h +1" as AppleScript

it should be easy !!! :(

Re: shutdown applescript wrong

Posted: Mon Feb 01, 2016 12:18 pm
by Klaus
Buongiorno Alessio,

I have no idea! :D

But since "-h +1" look like command line arguments maybe Applescript does not support them?
Did you try this in the AppleScript Editor? Did it work there?


Best

Klaus

Re: shutdown applescript wrong

Posted: Tue Feb 02, 2016 10:21 am
by AlessioForconi
Guten morgen Klaus :)

when run from terminal works properly, I believe that it is not supported. No matter, I'm trying with another instruction.

Questo funziona da Applescript

Code: Select all

do shell script "sleep 5" # 5 seconds
tell application "System Events"
shut down
end tell
e questo codice funziona in Livecode

Code: Select all

do "tell application" && quote & "System Events" & quote && "shut down " as AppleScript
ma se lo modifico in questo modo per ritardare lo shut down non va

Code: Select all

do "shell script" && quote & "sleep 5" & quote && "tell application" && quote & "System Events" & quote && "to shut down" as AppleScript

Re: shutdown applescript wrong

Posted: Tue Feb 02, 2016 10:46 am
by Klaus
Buongiorno Alessio,

well, my italian is very limited, but I understood what you wrote (I hope! :D )

But why bother with AppleScript*** and not use LC and SHELL directly?
...
wait 5 secs with messages
get shell "shutdown -h +1"
...
?
That should do the trick, I think.

***Did you know that Apple really thought about using HyperTalk,
yes the HyperCard langauge!, as the script language for Macs?
But unfortunately later the came up with ugly and clumsy AppleScript! :(


Best

Klaus

Re: shutdown applescript wrong

Posted: Tue Feb 02, 2016 10:51 am
by AlessioForconi
I understand what you say :)

What I want to do is to issue the shutdown command to the Mac but to delay of a few seconds to give way to the application from closing properly otherwise the next power sometimes happens that restarts and reimpartisce the shutdown command and so on in a loop :?

Re: shutdown applescript wrong

Posted: Tue Feb 02, 2016 12:29 pm
by Klaus
Ah, OK, then try:
...
get shell "sleep 5"
get shell "shutdown -h +1"
...
?