Return from command line executable

Is there a way to execute a command line executable and get the return?

do you mean like this.

tell application "Finder"
	set foo to selection as alias
end tell
set Command to do shell script "/Developer/Tools/GetFileInfo " & quoted form of POSIX path of foo

Command -- the info returned is held in this variable

The command line is /Developer/Tools/GetFileInfo foo

/Developer/Tools/GetFileInfo being the path to the exacutable
Do shell script is the Applescript wrapper for the shell script

In this example Applescript set variable to … is like in unix command=/Developer/Tools/GetFileInfo

peejavery, like mark said, the do shell script command can be used in a Studio app. (It’s in the Standard Additions dictionary.)

Well, I can’t get it exactly as you say. Let me explain myself.

I want to get the return from AMSTracker every 1/4 second. Basically, I want to make an application that will detect the sudden motion sensor and send keystrokes according to movement.

Anyone know how to do this?

I and not upto speed in xcode.

But in a applescript saved as an application


Property Last_Command : ""

on idle
	set Command to do shell script "./amstracker "
	if Command is equal to Last_Command then
		return 0.4
		
	else
		set Last_Command to Command
		tell application "System Events"
			beep
do shell script "echo " & Last_Command & " >> ~/documents/ams.log"
		end tell
		return 0.4
	end if
	
end idle 

Man is that sucker sensitive.
looking at the log file " ~/documents/ams.log" it would be best to only use the first orientation number:
example:
0 -3 56

the 0 number is the least likely to change on small vibrations.

Like this, seems to work but you can tweak it to be a sensitive as you want or use some of the other numbers.

property baseline : "0"
property Last_ams_check : ""
property CommandzLast : ""
on idle
	
	set Commandz to do shell script "/Users/UserName/Documents/AMSTracker"
	
	set ams_check to word 1 of paragraph 2 of Commandz
	if ams_check is equal to Last_ams_check then
		return 0.4
		
	else
		if ams_check is greater than baseline + 2 then
			
			tell application "System Events"
				beep
				
			end tell
			do shell script " echo " & "now _ " & paragraph 2 of Commandz & " before _" & CommandzLast & " >> ~/documents/ams.log"
			set Last_ams_check to ams_check
			set CommandzLast to paragraph 2 of Commandz
			return 0.4
		end if
		return 0.4
	end if
	--get Command
end idle

Perfect. Thank you very much.

One problem. If the first number is a negative, it returns the absolute value for that integer.

on the first number tilt to left seems to be in the negative. i.e -2

But as a test to see what i was actually getting in the script I ran

 set Commandz to do shell script "/Users/UserNamee/Documents/AMSTracker"
   
   set ams_check to word 1 of paragraph 2 of Commandz

on left tilt numbers returned come up as positive. the same on right tilt thats why I can use the base number.

Basically a tilt is a tilt

No. What I am saying is that if you move to -X it will always show it as positive X. Move the notebook left and it will show right movement because it cuts the “-” off of the variable by using the words function.

I think we are saying the same thing.
It all depends on what you want, if you want to show left tilt as a left tilt or a right tilt as a right tilt then just change the
way it picks out the numbers,

example:

set Commandz to do shell script "/Users/UserName/Documents/AMSTracker"

set ams_check to characters 3 thru 4 of paragraph 2 of Commandz as string
if character 3 of paragraph 2 of Commandz is " " then
	set ams_check to character 4 of paragraph 2 of Commandz as string
	
end if

set ams_check to ams_check as integer

Sorry but I have parsed it in so many ways. For some reason, once, you move the notebook around, it starts seeing everything as positive. I think it moves the characters around so that the negative symbol is no in character position #3.

EDIT: I solved it

repeat 50 times
	set theReturn to do shell script "Users/PaulAvery/Library/AMSTracker/AMSTracker"
	set theCoord to characters 1 through 5 of paragraph 2 of theReturn
	set theCoord to theCoord as string
	set xcoord to first word of paragraph 2 of theReturn as integer
	if theCoord contains "-" then set xcoord to -xcoord as integer
	
	if xcoord < -20 then display alert "Left" & (xcoord as string)
	if xcoord > 17 then display alert "Right" & (xcoord as string)
	
	delay 0.1
end repeat