AppleScript Terminal = Can't make into type number

Hi, all!


I've recently been having an AppleScript problem, concerning WINE. My script is as follows:

display dialog "Enter path of *.exe to run (in double quotation marks)." default answer ""

set exe_path to text returned of result


tell application "Terminal"

activate

do script "wine" + exe_path

end tell

My problem is that the program spits out:

error "Can’t make \"wine\" into type number." number -1700 from "wine" tonumber

I can't figure out why. Can anybody tell me?

FYI, I'm not a novice at AppleScript, but I'm not too complex and over-the-top of it, either. Please explain your answers a little so I can understand them.

Thanks in advance!

MacBook Pro, Mac OS X (10.7.5)

Posted on Dec 27, 2015 11:30 PM

Reply
5 replies
Sort By: 

Dec 28, 2015 12:12 AM in response to Sharkey101

Try running a debugging entry after line 2 of the quoted script above:


display dialog exe_path & "wine"


to check whether it's coming out in the correct format, e.g. Macintosh HD:Users:Fred:Documents and so on. Maybe "wine" needs to be preceded by a colon? However I don't know why it's falling over after 'do script'. You could try


set winepath to exe_path & "wine"

do script winepath


(All this is guesswork, you understand.)

Reply

Dec 28, 2015 12:50 AM in response to Roger Wilmut1

All of which raises some questions. What exactly is the file called 'wine'? And why run it in Terminal? Is it an application which runs when double-clicked? - if so you could just open it in Applescript using Finder. Why go to the trouble of entering the path manually? It is not always in the same place?


Looking at the Applescript dictionary for Terminal, 'do script' is to run a shell script or UNIX command - I would have thought this expected to be followed by the actual text of the script, as in


do shell script "curl www.bbc.co.uk"

Reply

Dec 28, 2015 2:45 PM in response to Roger Wilmut1

set winepath to exe_path & "wine"

do script winepath

Hmm. I got somewhere then. I had to enclose the "do script" inside a "tell application "Terminal"", but I did get somewhere. Terminal opened and typed up:

~/.wine/drive_c/Program\\ Files/7-Zip/7zFM.exewine

which means a command was spat out, around the wrong way, without a space in between.

Then I tried:

set winepath to "wine " & exe_path

tell application "Terminal"

do scriptwinepath

end tell

I got it to work, so thanks! You pointed me in the right direction! Pretty good guesswork! 😉


As for

All of which raises some questions. What exactly is the file called 'wine'? And why run it in Terminal? Is it an application which runs when double-clicked? - if so you could just open it in Applescript using Finder. Why go to the trouble of entering the path manually? It is not always in the same place?

Okay, 'wine' is a program that runs windows applications on mac. When you run 'wine path/to/exe/file.exe' in terminal, the exe will load on the mac. There is no GUI interface that I can find, so I decided to make a small, easy, one. (I like GUI better than command line. It is cleaner.)

I could also have made an AppleScript application that ran:

tell application 'Terminal'

do script "wine /Users/Ash/.wine/drive_c/Program\\ Files/example/file.exe"

end tell

to run individual applications, but that means a new script for each application.



The '~/.wine/drive_c' folder is equivalent to the emulated windows 'C:\' drive. More information on wine can be found at https://www.winehq.org/, and a simple way to get and compile it can be found at http://www.davidbaumgold.com/tutorials/wine-mac/.

Anyway, thanks, Roger Wilmut1. You were very helpful 🙂

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript Terminal = Can't make into type number

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.