Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mishamazor

macrumors newbie
Original poster
Dec 23, 2007
14
6
Trying to launch an app remotely thru ssh. Everything works, except my application name has spaces in it and I'm getting an Apple Script error on the syntax of the "open -a NET\ Render\ Client" string. How do I launch my "Net Render Client.app" with a script via Terminal?

Code:
tell application "Terminal"
    activate
    my execCmd("ssh me@hocalhost", 1)
    my execCmd("myPassw0rd", 0)
    my execCmd("open -a NET\ Render\ Client", 1)
    my execCmd("exit", 0)
end tell
on execCmd(cmd, wait)
tell application "System Events"
    tell application process "Terminal"
    set frontmost to true
    keystroke cmd
    keystroke return
    end tell
end tell
delay wait
end execCmd

Thanks!
Misha
 
I made a copy of TextEdit in my App folder, just so this script could open it.
Notice that its name contains a space. The 'quoted form' bit takes care of the problem

Code:
set apfolderpath to POSIX path of (path to applications folder as text)
set z to quoted form of (apfolderpath & "TextEdit copy.app")

do shell script "open " & z
TN2065 should clarify things 'do shell script', 'quoted form', and 'POSIX path' for you:
do shell script in AppleScript
 
Problem solved

Double backslash did the trick:

Code:
tell application "Terminal"
    activate
    my execCmd("ssh me@hocalhost", 1)
    my execCmd("myPassw0rd", 0)
    my execCmd("open -a NET\\ Render\\ Client", 1)
    my execCmd("exit", 0)
end tell
on execCmd(cmd, wait)
tell application "System Events"
    tell application process "Terminal"
    set frontmost to true
    keystroke cmd
    keystroke return
    end tell
end tell
delay wait
end execCmd
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.