Kinook Software Forums

Kinook Software Forums (http://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (http://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   DOSCMD recursive COPY NUL fails with exit code 104 (http://www.kinook.com/Forum/showthread.php?t=362)

philip 03-18-2004 11:41 AM

DOSCMD recursive COPY NUL fails with exit code 104
 
I have a step in a build that does:
%DOSCMD% FOR /R D:\directory /D %%f IN (*.*) DO COPY NUL %%f\Vers_081.txt

This is intended to create a 0-byte placeholder file in each subdirectory in the path. If I run the command (without the %DOSCMD% and changing the %%f to %f) from a DOS prompt, it works correctly.

When this is run in Visual Build, it fails with an error:
Process completed with exit code 104
although it appears to create all the placeholder files correctly. If I change the "COPY NUL" to "ECHO. > ", it still fails in Visual Build with the same message and exit code (but again, it does create the files).

This is version 5.0 of Visual Build (licensed) running on Windows NT4 SP6a.

kinook 03-20-2004 07:57 PM

I suspect that COPY is returning exitcode 104 in both scenarios, but is only being detected and aborted by VBP. You could add that code to the success codes for the Run Program step (0, 104 in the Success exit codes field).

philip 03-21-2004 06:38 PM

I tried the same command in a batch file, with a check for the ERRORLEVEL at the end of the batch file, and the ERRORLEVEL is 0 when run in a batch file.

kinook 03-21-2004 10:19 PM

To get an equivalent comparison with what VBP is doing when executing internal OS commands, create a .cmd script that looks like this:

cmd /c FOR /R D:\Directory /D %%f IN (*.*) DO COPY NUL %%f\Vers_081.txt
echo %ERRORLEVEL%

I'll bet that if you run this from a Command Prompt you'll get the same errorlevel/exitcode behavior as inside VBP (on Win XP, it shows an exitcode of 2012907760). The cmd /c part is necessary from within VBP since 'copy' is implemented by the command interpreter. I'm not sure why cmd.exe produces a different exitcode in this situation, but it sounds like a bug in Windows (unless there's something about the statement syntax that isn't technically valid, but then you would expect it to fail without doing anything).

kinook 04-01-2004 09:22 AM

This seems to be a general problem when calling cmd /c FOR. One workaround is to put the FOR call in a batch file (which tests the exitcode itself and performs a no-op statement to force a 0 exitcode on success). This can be copied/pasted into VBP:




%TEMP%\x.bat
@IF %%ERRORLEVEL%% == 0 GOTO Done
@rem this executes another statement that will succeed so the callee gets a 0 exitcode
:Done]]>

Create a temporary batch file to perform a FOR command and ensure a 0 exitcode on success when called via cmd /c
1
create batch file


%DOSCMD% call "%TEMP%\x.bat"
Call the temporary batch file that was created
1
call batch file
1


All times are GMT -5. The time now is 03:11 PM.


Copyright 1999-2019 Kinook Software, Inc.