terminal and spaces

Mac OSX specific forum
User avatar
J. Baker
Addict
Addict
Posts: 2111
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

terminal and spaces

Post 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)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3736
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: terminal and spaces

Post 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)
User avatar
J. Baker
Addict
Addict
Posts: 2111
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: terminal and spaces

Post 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! ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
collectordave
Addict
Addict
Posts: 1241
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: terminal and spaces

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Wolfram
Enthusiast
Enthusiast
Posts: 526
Joined: Thu May 30, 2013 4:39 pm

Re: terminal and spaces

Post 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)
User avatar
kenmo
Addict
Addict
Posts: 1897
Joined: Tue Dec 23, 2003 3:54 am

Re: terminal and spaces

Post 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.
Post Reply