Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exec command changing forward slash in windows & cmd.exe fails

94 views
Skip to first unread message

Keith

unread,
Nov 12, 2009, 12:31:30 PM11/12/09
to
(bin) 9 % exec cmd.exe /c edit.com

Works fine

(bin) 10 % set t "cmd.exe /c edit.com"
cmd.exe /c edit.com

(bin) 11 % exec $t &
couldn't execute "cmd.exe \c edit.com": no such file or directory
(bin) 12 %

the /c is changed to \c. I tried //c & \\c with the same results

I also put the full path to cmd.exe with the same results.

set t "C:/Windows/system32/cmd.exe /c edit.com"
set t "C:\\Windows\\system32\\cmd.exe /c edit.com"

exec C:/Windows/system32/cmd.exe /c edit.com

works fine.

This just started occurring and there was no problem earlier with the same
settings.

% echo $env(Path)
"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\QuickTime\QTSystem\;C:\Tcl\bin;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\QuickTime\QTSystem\\"
--
Best Regards, Keith
http://home.comcast.net/~kilowattradio/
Tired of Google Groups?
http://home.comcast.net/~kilowattradio/usenet.html

Óscar Fuentes

unread,
Nov 12, 2009, 1:15:31 PM11/12/09
to
Keith <kilowa...@use-reply-to.invalid> writes:

> (bin) 9 % exec cmd.exe /c edit.com
>
> Works fine
>
> (bin) 10 % set t "cmd.exe /c edit.com"
> cmd.exe /c edit.com
>
> (bin) 11 % exec $t &
> couldn't execute "cmd.exe \c edit.com": no such file or directory
> (bin) 12 %

exec expects the executable name as its first argument. When you do

exec $t

$t is taken as the name of the executable to run, hence it fails with
"no such file or directory" in your case.

Use

eval exec $t

This expands $t before calling exec and so it sees a list of arguments.

--
�scar

Keith

unread,
Nov 12, 2009, 1:26:57 PM11/12/09
to

Thanks for the tip.

0 new messages