Page 1 of 1

terminal and spaces

Posted: Thu Sep 01, 2011 2:26 pm
by J. Baker
As you can see below, the image name has a space in it. This should work but doesn't. Any thoughts?

Code: Select all

image$ = GetHomeDirectory() + "Desktop/image 2.png"
PreviewFix$ = ReplaceString(image$, " ", "\ ", 1, FindString(image$, " ", 1))
View = RunProgram("open", "-a /Applications/Preview.app " + PreviewFix$, "", #PB_Program_Open)
Debug PreviewFix$
CloseProgram(View)

Re: terminal and spaces

Posted: Thu Sep 01, 2011 2:49 pm
by wilbert
How about this ?

Code: Select all

image$ = Chr(34) + GetHomeDirectory() + "Desktop/image 2.png" + Chr(34)
View = RunProgram("open", "-a /Applications/Preview.app " + image$, "", #PB_Program_Open)
CloseProgram(View)

Re: terminal and spaces

Posted: Thu Sep 01, 2011 7:16 pm
by J. Baker
wilbert wrote:How about this ?

Code: Select all

image$ = Chr(34) + GetHomeDirectory() + "Desktop/image 2.png" + Chr(34)
View = RunProgram("open", "-a /Applications/Preview.app " + image$, "", #PB_Program_Open)
CloseProgram(View)
You're awesome, thanks wilbert! ;)

Re: terminal and spaces

Posted: Wed Jun 17, 2020 2:59 am
by collectordave
Having similar problem trying to mount a dmg.

hdiutil mount /Users/williamatkin/Documents/World\ Stamp\ Collector/Downloads/WorldStampCollector.dmg

works every time in terminal.

Tried

Code: Select all

   MountDMG.s  = "hdiutil mount " + Chr(34) + "/Users/williamatkin/Documents/World\ Stamp\ Collector/Downloads/WorldStampCollector.dmg" + Chr(34)

RunProgram("open", MountDMG, "", #PB_Program_Open)
and other combinations and it does nothing.

can anyone explain what I am doing wrong?

CD

Re: terminal and spaces

Posted: Wed Jun 17, 2020 10:59 am
by Wolfram
collectordave wrote:
can anyone explain what I am doing wrong?

CD

Code: Select all

Command.s  = "mount " + Chr(34) + "/Users/williamatkin/Documents/World\ Stamp\ Collector/Downloads/WorldStampCollector.dmg" + Chr(34)

RunProgram("hdiutil",  Command, "", #PB_Program_Open)

Re: terminal and spaces

Posted: Wed Jun 17, 2020 1:52 pm
by kenmo
** Not on a Mac to test right now, but

Code: Select all

MountDMG.s  = "hdiutil mount " + Chr(34) + "/Users/williamatkin/Documents/World\ Stamp\ Collector/Downloads/WorldStampCollector.dmg" + Chr(34)
It looks like you're mixing the double-quote method AND the backslash-space method?

Try taking out the backslashes before those spaces.


I think the backslash-space method is a feature of the Terminal, it is not universal like double-quoting, which I think was J. Baker's issue at the start of this thread.