PureBasic Forum
https://www.purebasic.fr/english/

terminal and spaces
https://www.purebasic.fr/english/viewtopic.php?f=19&t=47404
Page 1 of 1

Author:  J. Baker [ Thu Sep 01, 2011 2:26 pm ]
Post subject:  terminal and spaces

As you can see below, the image name has a space in it. This should work but doesn't. Any thoughts?
Code:
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)

Author:  wilbert [ Thu Sep 01, 2011 2:49 pm ]
Post subject:  Re: terminal and spaces

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

Author:  J. Baker [ Thu Sep 01, 2011 7:16 pm ]
Post subject:  Re: terminal and spaces

wilbert wrote:
How about this ?
Code:
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! ;)

Author:  collectordave [ Wed Jun 17, 2020 2:59 am ]
Post subject:  Re: terminal and spaces

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:
   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

Author:  Wolfram [ Wed Jun 17, 2020 10:59 am ]
Post subject:  Re: terminal and spaces

collectordave wrote:

can anyone explain what I am doing wrong?

CD


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

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

Author:  kenmo [ Wed Jun 17, 2020 1:52 pm ]
Post subject:  Re: terminal and spaces

** Not on a Mac to test right now, but
Code:
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.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/