AppleScript "do shell script" Error: "Cant' make...into type string."

Joined
Aug 28, 2016
Messages
1
Reaction score
0
Points
1
Hello!

I'm fairly new to AppleScript. I am working on a project in FileMaker Pro to "Perform AppleScript"
I have been testing some basic AppleScripts in Script Editor before transferring them and running them through FileMaker Pro, however.

In Script Editor I am getting the error:
Terminal got an error. Cant' make application "Terminal" into type string.

The Scripts I am entering are as such:

tell application "Terminal"
activate
do shell script
"say hello"
end tell


I've also tried

tell application "Terminal"
activate
do shell script
"system_profiler SPHardwareDataType"
end tell


The first time I attempted "say hello" it worked, but then suddenly it all stopped working and I continually get this error. I deleted all saved test scripts, and restarted my system even and it persists.

Any ideas!?

Thank you!
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Firstly when your activating another application like "Terminal", you have to allow time for the application to activate before passing it more instructions.
But in this case you don't even need to activate "Terminal", because the "do shell script" command is an "AppleScript" command, and not a "Terminal command, so "Terminal does not understand the instruction.

So in the "Script Editor" application, you can simply type this, and hit the run button in the "Script Editor" toolbar to hear and see the shell return result.

Code:
do shell script "say hello"

The Result display pane is at the bottom of the "Script Editor" applications window.
In the case of the simple script above, the return result is an empty string, as this shell command does not have a return value.

If you type your second example into the "Script Editor" like below, and hit the run button, you will see the returned result in the result pane as a string.

Code:
do shell script "system_profiler SPHardwareDataType"

You can then do something with the rsult if you typed your script like this.

Code:
set myResult to do shell script "system_profiler SPHardwareDataType"
-- Do something with the myResult variable
return myResult

I hope this helps.
But I would recommend learning the basics of AppleScript before moving on to more complex examples.
There are plenty of free online resources for learning AppleScript.

And in recent times you can even create fully fledged applications in Xcode with Applescript, and create a custom user interface for your applications as well.

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top