1. system_exec()

Hi system_exec() can't handle pathnames including spaces. On Windows this is a real problem.

My Question: Is this by design or is this a Windows problem?

Andreas

new topic     » topic index » view message » categorize

2. Re: system_exec()

andi49 said...

Hi system_exec() can't handle pathnames including spaces. On Windows this is a real problem.

My Question: Is this by design or is this a Windows problem?

Andreas

Windows requires that path names with spaces have to be enclose in quotes .

new topic     » goto parent     » topic index » view message » categorize

3. Re: system_exec()

HI

BRyan said...

Windows requires that path names with spaces have to be enclose in quotes .

Even quoting does not work with system_exec(), i have to pass every path through Getshortfilename(), this broke the setup for
for my modified Designer on WInXP.
As it uses %HOMEPATH% as the basediretory for created Projects.
On Win 6.0 and bigger this is okay (%HOMEPATH%=Drive:\users\username)}
But on XP this is 'Drive:\Documents and Settings\username'

Andreas

new topic     » goto parent     » topic index » view message » categorize

4. Re: system_exec()

andi49 said...

HI

BRyan said...

Windows requires that path names with spaces have to be enclose in quotes .

Even quoting does not work with system_exec(), i have to pass every path through Getshortfilename(), this broke the setup for
for my modified Designer on WInXP.
As it uses %HOMEPATH% as the basediretory for created Projects.
On Win 6.0 and bigger this is okay (%HOMEPATH%=Drive:\users\username)}
But on XP this is 'Drive:\Documents and Settings\username'

Andreas

When you use system_exec because you are using a sequence you have to escape the quotes

 "  \"Drive:\\Documents and Settings\\username\" " 
new topic     » goto parent     » topic index » view message » categorize

5. Re: system_exec()

BRyan said...

Windows requires that path names with spaces have to be enclose in quotes .

When you use system_exec because you are using a sequence you have to escape the quotes

 "  \"Drive:\\Documents and Settings\\username\" " 

Hi
From the manual...

[...] 
On WINDOWS, system_exec() does not allow the use of command-line redirection in command. 
Nor does it allow you to quote strings that contain blanks, such as file names. 
[...] 

Andreas

new topic     » goto parent     » topic index » view message » categorize

6. Re: system_exec()

Did you try it ?

new topic     » goto parent     » topic index » view message » categorize

7. Re: system_exec()

andi49 said...
BRyan said...

Windows requires that path names with spaces have to be enclose in quotes .

When you use system_exec because you are using a sequence you have to escape the quotes

 "  \"Drive:\\Documents and Settings\\username\" " 

Hi
From the manual...

[...] 
On WINDOWS, system_exec() does not allow the use of command-line redirection in command. 
Nor does it allow you to quote strings that contain blanks, such as file names. 
[...] 

Andreas

Hmm, this is curious. Have you tested it? Looking at the code that implements system_exec on windoze, it seems that there is actually rudimentary support for using double quotes and even escaping double quotes.

That comment may have been misplaced and intended for pipeio:exec(), where this windoze-only restriction still holds true.

If it doesn't work, then - based on the clear intention of the code - I'd say that Euphoria would have a bug that needs to be fixed. It's definitely not a design feature for quotes and spacing to be unsupported.

new topic     » goto parent     » topic index » view message » categorize

8. Re: system_exec()

BRyan said...

Did you try it ?

Yes, i tried it ...

The problem is not, to work around it. The problem is, i do not know where this case appears.
So at the end, i have to pass everything through GetShortFilename() to just get sure it works...

Not very satisfying to put everything back to the old 8.3 Filenames...

Maybe it is an Windows issue, i just don't know.

(BTW: MCI_SendString() has the same problem)

Andreas

new topic     » goto parent     » topic index » view message » categorize

9. Re: system_exec()

andi49 said...
BRyan said...

Did you try it ?

Yes, i tried it ...

The problem is not, to work around it. The problem is, i do not know where this case appears.
So at the end, i have to pass everything through GetShortFilename() to just get sure it works...

Not very satisfying to put everything back to the old 8.3 Filenames...

Maybe it is an Windows issue, i just don't know.

(BTW: MCI_SendString() has the same problem)

Andreas

Andreas 
 
Why don't you just post an example of what you are trying to do 
and I am sure someone can help you. 
 
It is allot easier if we can see your code. 
 

}}}

new topic     » goto parent     » topic index » view message » categorize

10. Re: system_exec()

include std/console.e 
sequence string 
 
string = "\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\"" 
system_exec(string) -- This works 
puts(1,string&"\n") 
any_key() 
 
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe C:\\Program Files (x86)\\EuDesigner\\license.txt\"" 
system_exec(string) -- This not 
puts(1,string&"\n") 
any_key() 
 
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\""&" "&"\"C:\\Program Files (x86)\\EuDesigner\\license.txt\"" -- This not. Just Starts the Editor 
system_exec(string) 
puts(1,string&"\n") 
any_key() 
 

new topic     » goto parent     » topic index » view message » categorize

11. Re: system_exec()

 
-- Name this file test.exw and run it with euiw.exe This code tested 
-- Examine your quotes and compare to these. 
 
include std/console.e  
sequence string  
  
string = " \"C:\\Program Files (x86)\\EuDesigner\\edit.exe\" "  
system_exec(string) -- This works  
puts(1,string&"\n")  
any_key()  
 
new topic     » goto parent     » topic index » view message » categorize

12. Re: system_exec()

andi49 said...
string = "\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\"" 
system_exec(string) -- This works 
puts(1,string&"\n") 
any_key() 

It should.

andi49 said...
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe C:\\Program Files (x86)\\EuDesigner\\license.txt\"" 
system_exec(string) -- This not 
puts(1,string&"\n") 
any_key() 

It shouldn't. That makes it look like you have a big txt file called "C:\Program Files (x86)\EuDesigner\edit.exe C:\Program Files (x86)\EuDesigner\license.txt" that you want to run.

andi49 said...
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\""&" "&"\"C:\\Program Files (x86)\\EuDesigner\\license.txt\"" -- This not. Just Starts the Editor 
system_exec(string) 
puts(1,string&"\n") 
any_key() 

This should have worked. I'm not sure why it failed. Does something like this work?

string="\"C:\\Windows\\System32\\notepad.exe\""&" "&"\"C:\\Program Files (x86)\\EuDesigner\\license.txt\"" 
system_exec(string) 
puts(1,string&"\n") 
any_key() 

I wonder if spawnvp() simply can't deal with spaces in its arguments but requires them to be quoted. (IMNSHO it shouldn't, but this is windoze after all.) So that suggests another thing to try is this:

string="\"C:\\Windows\\System32\\notepad.exe\""&" "&"\"\\\"C:\\Program Files (x86)\\EuDesigner\\license.txt\\\"\"" 
system_exec(string) 
puts(1,string&"\n") 
any_key() 
new topic     » goto parent     » topic index » view message » categorize

13. Re: system_exec()

BRyan said...
 
-- Name this file test.exw and run it with euiw.exe This code tested 
-- Examine your quotes and compare to these. 
 
include std/console.e  
sequence string  
  
string = " \"C:\\Program Files (x86)\\EuDesigner\\edit.exe\" "  
system_exec(string) -- This works  
puts(1,string&"\n")  
any_key()  
 

?
This allready works...
Again... with working code included...

include tinewg.exw 
include std/console.e 
sequence string,string1 
string = "\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\"" 
system_exec(string) -- This works 
puts(1,string&"\n") 
 
any_key() 
 
 
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe C:\\Program Files (x86)\\EuDesigner\\license.txt\"" 
 
system_exec(string) -- This not 
puts(1,string&"\n") 
 
any_key() 
 
string="\"C:\\Program Files (x86)\\EuDesigner\\edit.exe\""&" "&"\"C:\\Program Files (x86)\\EuDesigner\\license.txt\"" -- This not. Just Starts the Editor 
system_exec(string) 
puts(1,string&"\n") 
 
any_key() 
 
string1=ShortFileName("C:\\Program Files (x86)\\EuDesigner\\edit.exe") 
string=ShortFileName("C:\\Program Files (x86)\\EuDesigner\\license.txt") 
 
system_exec(string1&" "&string) -- This does what it should do!!!! Starting the Editor with the file loaded 
puts(1,string1&" "&string) 
 
any_key() 

ShortFilename() just creates an 8.3 Filename using GetShortFileNmae() from the Win32Api
Any help is really welcome
Maybe i just misunderstood how to use system_exec()
Andreas

new topic     » goto parent     » topic index » view message » categorize

14. Re: system_exec()

Andreas, I thought it should work that way too so I did some tests and found a problem when Eu4 parses the arguments to be sent to spawnvp method. It basically removes the quotes around the parameters before sending them.

I did a patch to correct this, it's on http://openeuphoria.org/pastey/223.wc , you'll have to recompile the interpreter (I can provide you stripped binaries if you need to). I'm not very good at C so I cannot guarantee the code is 100% correct, if someone wants to review it I'll be glad to fix it.

Cheers,

Guillermo Bonvehi

PS: The patch was created using Euphoria 4.0.5 source.
Forked into: gbonvehi as dev?

new topic     » goto parent     » topic index » view message » categorize

15. Re: system_exec()

jimcbrown said...

[...] I wonder if spawnvp() simply can't deal with spaces in its arguments but requires them to be quoted. (IMNSHO it shouldn't, but this is windoze after all.) So that suggests another thing to try is this:

string="\"C:\\Windows\\System32\\notepad.exe\""&" "&"\"\\\"C:\\Program Files (x86)\\EuDesigner\\license.txt\\\"\"" 
system_exec(string) 
puts(1,string&"\n") 
any_key() 

This works.
Maybe gbonvehi found a solution. http://openeuphoria.org/pastey/223.wc
Andreas

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu