On Sat, 4 May 2002, Greg Conway wrote:

> @echo off
> c:\navdx\navdx.exe c:\virusfolder /s+ /doallfiles /zips /delete
> if errorlevel 13 echo "virus"
> if errorlevel 0 echo "clear"
>
>
> simple stuff. Under Win2K, this program does the decent thing and returns
> "virus" and "clear", as expected (DOS errorlevel command reports >= rather
> then = if I remember correctly!), if I drop the EICAR test files into the
> directory c:\virusfolder.
>
> However, under DOSEMU (I'm running the binaries with FreeDOS) it returns
> errorlevel 0 every time.

it appears that the "if errorlevel" itself should not set the errorlevel
then (to what "echo" returns, i.e., 0).
"echo" is an internal command so it should not give rise to an errorlevel.
this look like a bug in the built-in DOSEMU command.com: it does not
distinguish between external and internal "errorlevels".
a patch is below (Hans, I hope that is a good way of fixing it?).

you could also try to download FreeCOM and see if that helps.

> Once I have this sorted, my final problem will be to return the errorlevel
> to Linux, where I've called DOSEMU from a shell
> script, so if anybody has any ideas on this as well they'd be gratefully
> received - the best I've found is a posting so far
> that says "how does it work? exitemu 1 doesn't do the job"!!)

you'll need to do an INT E6 with AX=FFFF and the errorlevel in BL.
exitemu does not get BL from the commandline right now. Should be
straighforward to correct though. Or you could write a small program that
does that yourself.

I'll see about that and will post a patch for that later.

Bart

--- src/plugin/commands/comcom.c.old    Sat Mar 30 21:07:25 2002
+++ src/plugin/commands/comcom.c        Sun May  5 01:39:09 2002
@@ -104,6 +104,7 @@
 struct res_dta {
        struct batchdata *current_bdta;
        int exitcode;
+       int errorlevel; /* exit code for external commands */
        int need_errprinting;
        int echo_on;
        int envsize;    /* size of enlarged enviroment */
@@ -1277,7 +1278,7 @@
        if (!strcasecmp(argv[argi], "errorlevel")) {
                if (argi+2 >= argc) return DOS_EINVAL;
                level = strtoul(argv[argi+1], 0, 10);
-               if (((EXITCODE >= level) ? 1 : 0) ^ invers) {
+               if (((rdta->errorlevel >= level) ? 1 : 0) ^ invers) {
                        argi += 2;
                        SET_CHILD_ARGS(argi);
                        dopath_exec(argc-argi, argv+argi);
@@ -2740,6 +2741,7 @@
        saved_cannotexit = rdta->cannotexit;
        rdta->cannotexit = 0;
        ret =  load_and_run_DOS_program(name, cmdline);
+       rdta->errorlevel = ret;
        rdta->cannotexit = saved_cannotexit;

        /* re-enlarge the environment to maximum */
@@ -3256,6 +3258,7 @@
        rdta->need_errprinting = 0;

        EXITCODE = 0;
+       rdta->errorlevel = 0;
        ECHO_ON = 1;

        /* first free all memory we don't need for ourselves, such that


-
To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to