RunProgram() Path

Mac OSX specific forum
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

RunProgram() Path

Post by Wolfram »

Hi,

I try to write a GUI for dd copy.
The problem I have is, I have no Idea how to write the file path of the source if it has a space in it.
The normal path is "/my image.img" of couse in terminal if have to write "/my\ image.img"
But both doesn't work if I use it in my code.

Code: Select all

RunProgram("/bin/dd", "if=/my\ image.img of=/dev/disk1 bs=1m", "", #PB_Program_Open
Dose anyone has an idea?

Thanks
macOS Catalina 10.15.7
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: RunProgram() Path

Post by J. Baker »

Wilbert showed me this a while back...

Code: Select all

RunProgram("/bin/dd", Chr(34) + "if=/my image.img of=/dev/disk1 bs=1m" + Chr(34), "", #PB_Program_Open)
www.posemotion.com

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


Even the vine knows it surroundings but the man with eyes does not.
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

Re: RunProgram() Path

Post by Wolfram »

Thanks, but it dose not work for me.

Do you have any other idea?
macOS Catalina 10.15.7
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: RunProgram() Path

Post by wilbert »

Did you try the command from the terminal to see if the command itself works fine ?
Any reason not to use the PureBasic CopyFile() procedure ?
Windows (x64)
Raspberry Pi OS (Arm64)
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

Re: RunProgram() Path

Post by Wolfram »

Hi Wilbert,

in terminal it works. I have to write "my\ image" instate of "my image" than it works.
I have this problem only if I have a " " or other non standard letters like "ä" in the path.

I'm doing it this way because I copy images of a file system which is not supported by OSX.
macOS Catalina 10.15.7
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: RunProgram() Path

Post by wilbert »

I don't have a disk attached but you can try the example Joe gave you with the backslash included.

Code: Select all

RunProgram("/bin/dd", Chr(34) + "if=/my\ image.img of=/dev/disk1 bs=1m" + Chr(34), "", #PB_Program_Open)
If the destination file doesn't already exist, you could also try if NSFileManager works.

Code: Select all

FileManager = CocoaMessage(0, 0, "NSFileManager defaultManager")
CocoaMessage(0, FileManager, "copyItemAtPath:$", @"MySourceFile.txt", "toPath:$", @"MyDestinationFile.txt", "error:", #nil)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: RunProgram() Path

Post by Danilo »

Putting 'if=' and 'of=' in separate double quotes works here:

Code: Select all

Macro DQ(string)
    #DQUOTE$+string+#DQUOTE$
EndMacro

RunProgram("/bin/dd",DQ("if=/users/danilo/test.rtf")      +" "+DQ("of=/users/danilo/test 1 2 3.rtf")      +" bs=1m", "", #PB_Program_Wait)
RunProgram("/bin/dd",DQ("if=/users/danilo/test 1 2 3.rtf")+" "+DQ("of=/users/danilo/test 1 2 3 (new).rtf")+" bs=1m", "", #PB_Program_Wait)
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

Re: RunProgram() Path

Post by Wolfram »

This works!
...with space or "!" but not with "ä" or "ü"

This is not so important for me but let me know if you find a reason why.

Happy new year!!!
macOS Catalina 10.15.7
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: RunProgram() Path

Post by wilbert »

Wolfram wrote:but not with "ä" or "ü"
Did you compile with unicode support enabled ?
Windows (x64)
Raspberry Pi OS (Arm64)
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

Re: RunProgram() Path

Post by Wolfram »

Happy New year Wilbert!

you are the man! :D
macOS Catalina 10.15.7
Post Reply