Using ooREXX V4.0.0 on Win XP Pro
I have an existing home-grown function I use for wrapping redirection of
stdout (and sometimes stderr) when I call a command-line program under
Windows XP Pro. Usually the programs I call are either part of Windows or
utilities I've placed in a directory which is on PATH.
In execs where I plan to use such things I normally start by issuing a test
form of the command to check I get an expected simple response.
So for example with a utility called "id3.exe" I'll predefine the name of a
temporary file then do something like:
cmd = "id3 -V >" tempfile /* get version-no of id3.exe */
cmd ; cmdrc = rc
and go on to process the contents of the temporary file. The temporary
files I use often have spaces in their names so actually I create cmd as:
cmd = "id3 -V >" '"'tempfile'"'
Yesterday I tried to call 'curl' this way. However my copy of curl.exe is
not in a directory that's on PATH, because it and several other programmes
I'd like to have on PATH use different versions of some standard DLLs. If I
put any one set of utility programs and its DLLs into a directory on PATH
then I can't put other utility programs that'd use the same-named DLLs into
the same directories... so I've chosen to keep all of them elsewhere.
Anyway I ended up with a command string like:
cmd = '"C:\full\path\to\curl.exe" -V > "C:\full\pathto\tempfile.txt"'
and... it didn't work. No output was written to the tempfile. But if I c&p
the command that was in cmd into a (cmd.exe) command window, it does work.
For ages I thought this was a curl problem, then (when I tried other
utilities' names instead of curl.exe) I thought it was a Windows problem
(but the failing commands always work in command windows), so now I think
it's an ooREXX problem.
I wrote a test program to issue commands in various slightly different ways;
it logs the exact commands it issues and the sizes of the temporary file
used for each attempt (and the size of a file that's written to if a test
file name isn't enclosed in quotes), and also the contents of both those
files after issuing each command. It summarises command, rc, file
existence/sizes for each attempt. So issuing
edlin /?
in various ways and redirecting output I get:
#ec=01 TM=0005, C-VF=NO for: edlin /? > C:\vv1-cmd1a.txt
#ec=02 TM=0005, C-VF=NO for: edlin /? > "C:\vv1-cmd1b.txt"
#ec=03 TMPF=NO, CV=0005 for: edlin /? > C:\v v\1-cmd1c.txt
#ec=04 TM=0005, C-VF=NO for: edlin /? > "C:\v v\1-cmd1d.txt"
#ec=05 TM=0005, C-VF=NO for: edlin.exe /? > C:\vv1-cmd2a.txt
#ec=06 TM=0005, C-VF=NO for: edlin.exe /? > "C:\vv1-cmd2b.txt"
#ec=07 TMPF=NO, CV=0005 for: edlin.exe /? > C:\v v\1-cmd2c.txt
#ec=08 TM=0005, C-VF=NO for: edlin.exe /? > "C:\v v\1-cmd2d.txt"
#ec=09 TM=0005, C-VF=NO for: "C:\WINDOWS\system32\edlin.exe" /? >
C:\vv1-cmd3a.txt
#ec=10 TMPF=NO, C-VF=NO for: "C:\WINDOWS\system32\edlin.exe" /? >
"C:\vv1-cmd3b.txt"
#ec=11 TMPF=NO, CV=0005 for: "C:\WINDOWS\system32\edlin.exe" /? > C:\v
v\1-cmd3c.txt
#ec=12 TMPF=NO, C-VF=NO for: "C:\WINDOWS\system32\edlin.exe" /? > "C:\v
v\1-cmd3d.txt"
In each of these log summary lines the TMPF=NO or TM=nnnn value says whether
the expected tempfile was not created, or had nnnn (0 or more) lines. The
similar C-VF=NO or CV=nnnn value refers to a file called "C:\v" which is
accidentally created and written to when a tempfile with a name like
C:\v v\1-cmd2c.txt
is not wrapped up in quotes properly. The 12 tests above show that edlin /?
creates 5 lines of output in the expected temporary file or the accidentally
specified one for 10 of the 12 tests. The remaining two tests generated no
output at all, that is, for command strings containing:
"C:\WINDOWS\system32\edlin.exe" /? > "C:\vv1-cmd3b.txt"
"C:\WINDOWS\system32\edlin.exe" /? > "C:\v v\1-cmd3d.txt"
When either of these commands is c&p into a command window, it works.
Note that the double-quotes shown are all part of the commands.
It seems to me that the combination of enclosing the .exe's full path in
quotes AND enclosing the temporary file's full path in quotes, causes a
problem when the command is issued from ooREXX.
Does anyone have any idea what's going on, before I raise a bug report?
I've done the same thing with the same behaviour for 4 separate utility
programs (mainly ones that normally process MP3 files), and curl, as well as
for "edlin" and "ipconfig" which are part of windows, and it seems to me to
be the same behaviour in each case.
Here's the same thing for: ipconfig /?
#ec=01 TM=0039, C-VF=NO for: ipconfig /? > C:\vv2-cmd1a.txt
#ec=02 TM=0039, C-VF=NO for: ipconfig /? > "C:\vv2-cmd1b.txt"
#ec=03 TMPF=NO, CV=0039 for: ipconfig /? > C:\v v\2-cmd1c.txt
#ec=04 TM=0039, C-VF=NO for: ipconfig /? > "C:\v v\2-cmd1d.txt"
#ec=05 TM=0039, C-VF=NO for: ipconfig.exe /? > C:\vv2-cmd2a.txt
#ec=06 TM=0039, C-VF=NO for: ipconfig.exe /? > "C:\vv2-cmd2b.txt"
#ec=07 TMPF=NO, CV=0039 for: ipconfig.exe /? > C:\v v\2-cmd2c.txt
#ec=08 TM=0039, C-VF=NO for: ipconfig.exe /? > "C:\v v\2-cmd2d.txt"
#ec=09 TM=0039, C-VF=NO for: "C:\WINDOWS\system32\ipconfig.exe" /? >
C:\vv2-cmd3a.txt
#ec=10 TMPF=NO, C-VF=NO for: "C:\WINDOWS\system32\ipconfig.exe" /? >
"C:\vv2-cmd3b.txt"
#ec=11 TMPF=NO, CV=0039 for: "C:\WINDOWS\system32\ipconfig.exe" /? > C:\v
v\2-cmd3c.txt
#ec=12 TMPF=NO, C-VF=NO for: "C:\WINDOWS\system32\ipconfig.exe" /? > "C:\v
v\2-cmd3d.txt"
--
Jeremy C B Nicoll - my opinions are my own.
Email sent to my from-address will be deleted. Instead, please reply
to
newsre...@wingsandbeaks.org.uk replacing "aaa" by "284".