Applescript Progress

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
revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 49
Joined: Sat Apr 02, 2011 4:06 pm

Applescript Progress

Post by revRider » Mon Apr 09, 2012 2:16 pm

Good day..

In an application we are writing to bind macs to our network we execute a AppleScript

Code: Select all

      put empty into myresults
      put thePath & "/BindingScript.scpt"  into theUnixPath 
      put  EmployeeNumber &&  EmployeePassword && MailCode && OULevel && DCSelect && ComputerName  into tScriptCommand
      set the thumbPosition of scrollbar "Progress" to 10
      put shell ("osascript"&& quote & theUnixPath & quote && tScriptCommand)
      put the result into myresults
      put theUnixPath && tScriptCommand into script
We are finding once we shell out to the script we would like to update/display progress. Right now we are using speech prompts to inform the tech of script progress. (note Progress scrollbar)

Is there a way to get Applescript to 'report' back to the main program without having to redo the entire logic of the main program?

We attempted to break the script up into smaller script, but that would require multi inputs of the Administrators password (a no go).

We attempted to hard code the script into LiveCode, became to confusing due to all the quotes (") and very timing consuming to code.

is there a handshake back to the main program, allowing us to pass information back and forth? Any examples online?

The purpose of the program is to provide a means for non-Mac Techs to bind macs to Active Directory.
(Works great in PRE-Lion OSes, Lion is being a Bear! - Using speech as a prompt, but visual would be better).

Thanks.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Applescript Progress

Post by mwieder » Mon Apr 09, 2012 5:23 pm

Is there a reason you need to invoke osascript to run the Applescript?

If you place the Applescript text into a variable you can run it from LiveCode with

Code: Select all

do tScript as Applescript
That way you could break it into smaller chunks and give feedback with each and still only require getting the password once, since it's otherwise contained within the LC code.

... and Ken Ray has shared a very useful function for dealing with those annoying quotes:

Code: Select all

function q pText
  return quote & pText & quote
end q

-- put q(TextToQuote) into tTextSurroundedByQuotes

Post Reply