Run a applescript as shell script

Posted on
Tue May 19, 2015 12:41 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Run a applescript as shell script

I am trying to run a AppleScript as a shell script. As far as I have understood it is better to run scripts like these in a separate process. Can someone advice on what I am missing in my script. I have saved the script as application. I think I need the right syntax in the start of the script, but I don't want to just shoot in the dark and copy something I have found on google... :)


I have the following script stored in a folder.

Code: Select all
tell application "SecuritySpy"
   capture image camera number 0 as "/Users/Server/Documents/SecuritySpy/Doorbell/picture1.jpg" with overwrite
   delay 1
   capture image camera number 0 as "/Users/Server/Documents/SecuritySpy/Doorbell/picture2.jpg" with overwrite
   delay 2
   capture image camera number 0 as "/Users/Server/Documents/SecuritySpy/Doorbell/picture3.jpg" with overwrite
   delay 2
   capture image camera number 0 as "/Users/Server/Documents/SecuritySpy/Doorbell/picture4.jpg" with overwrite
end tell

tell application "Mail"
   
   set theSubject to "Ringeklokke aktivert" -- the subject
   set theContent to "Noen er ved døra" -- the content
   set theAddress to "MYMAIL" -- the receiver
   set theAttachmentFile1 to "Macintosh HD:Users:Server:Documents:Securityspy:Doorbell:picture1.jpg"
   set theAttachmentFile2 to "Macintosh HD:Users:Server:Documents:Securityspy:Doorbell:picture2.jpg"
   set theAttachmentFile3 to "Macintosh HD:Users:Server:Documents:Securityspy:Doorbell:picture3.jpg"
   set theAttachmentFile4 to "Macintosh HD:Users:Server:Documents:Securityspy:Doorbell:picture4.jpg"
   
   set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
   
   tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
   tell msg to make new attachment with properties {file name:theAttachmentFile1 as alias}
   tell msg to make new attachment with properties {file name:theAttachmentFile2 as alias}
   tell msg to make new attachment with properties {file name:theAttachmentFile3 as alias}
   tell msg to make new attachment with properties {file name:theAttachmentFile4 as alias}
   
   send msg
end tell

Håvard

Posted on
Tue May 19, 2015 2:10 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Run a applescript as shell script

I have done some more searching, at it appears as if I run a script as "file" the script will run as a separate process. Is this the case?
If this is the case, then I don't see the point of running this script as a shell script...

Håvard

Håvard

Posted on
Tue May 19, 2015 7:25 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Run a applescript as shell script

I believe it is the case, scripts stored as files run in a separate process. All my important or large scripts run in separate files, only the short ones run directly in an Indigo window.

But why don't you prefer to use Security Spy itself to email images ?

Posted on
Tue May 19, 2015 11:22 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Run a applescript as shell script

I run it from Indigo because it is triggered by the doorbell. But maybe I could have done that from SS.

Håvard

Håvard

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 28 guests