shutdown applescript wrong

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

shutdown applescript wrong

Post by AlessioForconi » Mon Feb 01, 2016 11:44 am

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 !!! :(

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: shutdown applescript wrong

Post by Klaus » Mon Feb 01, 2016 12:18 pm

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

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: shutdown applescript wrong

Post by AlessioForconi » Tue Feb 02, 2016 10:21 am

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: shutdown applescript wrong

Post by Klaus » Tue Feb 02, 2016 10:46 am

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

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: shutdown applescript wrong

Post by AlessioForconi » Tue Feb 02, 2016 10:51 am

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 :?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: shutdown applescript wrong

Post by Klaus » Tue Feb 02, 2016 12:29 pm

Ah, OK, then try:
...
get shell "sleep 5"
get shell "shutdown -h +1"
...
?

Post Reply