[erlang-questions] how to open_port with spaces in path?
Serge Aleynikov
serge@REDACTED
Mon Feb 12 14:44:06 CET 2007
Since this seems to be a known bug, you may try some workarounds. The
most obvious one is to rename a directory so that it doesn't contain
spaces. The less obvious one is to find out what is the "short name" of
a directory, and use that instead:
c:\temp>dir /X /AD "a*"
Volume in drive C is unlabeled Serial number is 381F:4FF1
Directory of C:\temp\a*
2/12/07 8:31 <DIR> AA0919~1 a a
0 bytes in 0 files and 1 dir
3,814,490,112 bytes free
In the example above "AA0919~1" is the equivalent name of the "a a"
directory:
c:\temp>dir "AA0919~1"
Volume in drive C is unlabeled Serial number is 381F:4FF1
Directory of C:\temp\AA0919~1\*
2/12/07 8:31 <DIR> .
2/12/07 8:31 <DIR> ..
2/12/07 8:31 0 my.exe
0 bytes in 1 file and 2 dirs 0 bytes allocated
3,814,490,112 bytes free
Serge
P.S. This second workaround doesn't seem very appealing, but if you
can't possibly change directory names, this may be your only option.
Denis Bilenko wrote:
> Hello,
> I'm trying to execute external program which happened to have spaces in
> path (not uncommon on windows). open_port exits with einval:
>
> 56> open_port({spawn, "D:/a a/my.exe"}, []).
>
> =ERROR REPORT==== 11-Feb-2007::23:59:35 ===
> Error in process <0.102.0> with exit value:
> {einval,[{erlang,open_port,[{spawn,"D:/a a/my.exe"},[]]},{erl_eval
> ,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
> ** exited: {einval,[{erlang,open_port,[{spawn,"D:/a a/my.exe"},[]]},
> {erl_eval,do_apply,5},
> {shell,exprs,6},
> {shell,eval_loop,3}]} **
>
> I've tried to use quotes
>
> 57> open_port({spawn, "\"D:/a a/my.exe\""}, []).
>
> it doesn't change anything.
>
> Googling revealed this:
> Known problems
> * os:cmd on WIN32 does not always catch the output from the executed program
> correctly. There is also a problem with executing programs with
> space in the path.
> http://www.erlang.org/doc/doc-4.8.2/erts-4.8.2/notes_history.html
>
> It was not fixed? Are there any workarounds?
>
> erl: 5.5.3
> os: winxp
>
> /Denis.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list