10 Replies Latest reply: Dec 22, 2012 2:02 PM by wiinick100
wiinick100 Level 1 (0 points)

I have spent hours trying to figure this out, automator is the hardest thing to figure out. All I want to do is emulate me doing this

-Open terminal

-type wine

-drag and drop the location of an .exe file

-hit enter

 

Now this should be easy as all I have to do is do run shell script, insert argument and done, BUT IT DOESNT RECOGNIZE WINE!?!?! Pleas help me.

 

Let me clarify.

If I make an automator application that that runs the command "wine" and then inserts text into the space after that Then i will be set. But no matter what I do nothing works. If i set the shell to perl and pass input as argument....It doesnt work the $f and $@ stuff doesnt work.

 

Wine is likely not recognized because is is pearl based so I set it to pearl, but how do i pass and argument over to it?


MacBook Pro, Mac OS X (10.7.4)
  • Camelot Level 8 (46,650 points)

    Well, for one I suspect you're doing it wrong

     

    What's your rationale for driving Terminal.app to do this simple task (launch an application) vs. some of the other Automator actions such as Execute New UNIX Task, or even just Run Shell Script. Both of these can run without needing Terminal.app

     

    If you insist on using Terminal, I suspect your problem has something to do with paths - if wine isn't in the standard system directories (e.g. /bin, /sbin, /usr/bin, etc.) then the OS won't find it unless you use the full path to the wine executable (e.g. /usr/local/wine, /opt/wine, or wherever you've installed it on your machine).

  • wiinick100 Level 1 (0 points)

    Thank you I will try this.

     

    My rational is that when one drags and drops a file onto an application, that application tries to open it. I can get the drag and drop action to copy the files location and turn it into an argument. Just no clue and how to insert it into "wine (Argument goes here)" just as if I typed wine /Users/Nicks/Desktop/putty.exe

    Then that would run putty.exe on my mac using wine.

  • wiinick100 Level 1 (0 points)

    Here is what ive got

     

    tell application "Terminal"

              do script "/opt/local/bin/wine"

    end tell

     

    This runs nicely. Ok so now how to I get the output from the last action to insert into this. This is an applescript.

     

    I want it to look like

    tell application "Terminal"

              do script "/opt/local/bin/wine /Users/Nicks/Desktop/putty.exe"

    end tell


     


  • Camelot Level 8 (46,650 points)

    I still think you're on a losing track by using Terminal.app.

     

    Recreate your workflow as an application (Automator applications accept files drag/dropped on the app icon). In the workflow add the 'Run Shell Script' action with the script:

     

    /opt/local/bin/wine ${0}

     

    That should do what you need (error handling notwithstanding (e.g. you drop a directory or non .exe file on the app)

  • wiinick100 Level 1 (0 points)

    it fails. it states

     

    "Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!"

     

    This error is expected and everything still runs if I do it in terminal. But this immediately stops the whole operation at that error.

  • wiinick100 Level 1 (0 points)

    WAIT!!! I replaced the 0 with a 1 (for no reason) and it worked!!!

     

    THANK YOU SO MUCH. Ive been working on this for hours.

     

    Now I can set all my .exe files to open with that application.

  • wiinick100 Level 1 (0 points)

    GAH it works for putty.exe but I try a game called little inferno and it failes giving the error of (2)

    I need it to handle errors

  • wiinick100 Level 1 (0 points)

    Wait...if I run any exe from the desktop it works...anywhere else it fails...

     

    So I have all exe files set to open with that application. Everything from the desktop works. I dun get it.!?!?!

     

    Ok so problem solved. Anything with a space in it will not work because the shell wont except them without \\. I had a folder called Windows Applications.

    Any Idea on how to bypass the space issue without doing Windows\\ Applications

  • BobHarris Level 6 (17,689 points)

    Try

     

    /opt/local/bin/wine "$@"
    

     

    The "..." will protect the white space, but still allow $variable subsitutions.

     

    The $@ will substitute all the files you drag as a group to your Automator app.

     

    The notation "$@" does the substitution with each file properly quoted to protect the white space in the file path, but provide each file as its own quoted argument to the 'wine' command line.

     

    If you need to invoke 'wine' once for each file of a group of files you drag on to your automator app, then use

     

    for f in "$@"
    do
         /opt/local/bin/wine "$f"
    done
    

     

    This will loop through each file of a group of files you drag onto your automator app, and invoke 'wine' once for each file in the group.

  • wiinick100 Level 1 (0 points)

    It works, it gives an error at the end of each run saying automator didnt run properly but everything works.

     

    I tried

    /opt/local/bin/wine "$@" which did work without errors but when i tried putty.exe (An ssh client) it said could not connect to host ~/Desktop. Which is just a strange error if you ask me. Especially if Its a startup error for the program. Dont know what thats about but Thank you for all the help I can deal with an error at the end of each run.

    YOU SIR ARE A GENIOUS