Page 1 of 1

RunProgram() Path

Posted: Tue Dec 31, 2013 1:02 am
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

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 4:30 am
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)

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 1:40 pm
by Wolfram
Thanks, but it dose not work for me.

Do you have any other idea?

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 1:46 pm
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 ?

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 2:42 pm
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.

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 3:16 pm
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)

Re: RunProgram() Path

Posted: Tue Dec 31, 2013 5:23 pm
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)

Re: RunProgram() Path

Posted: Wed Jan 01, 2014 1:06 pm
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!!!

Re: RunProgram() Path

Posted: Wed Jan 01, 2014 1:17 pm
by wilbert
Wolfram wrote:but not with "ä" or "ü"
Did you compile with unicode support enabled ?

Re: RunProgram() Path

Posted: Wed Jan 01, 2014 1:34 pm
by Wolfram
Happy New year Wilbert!

you are the man! :D