Once you have debugged ALL your batch files you can place `CTTY NUL' before
the command(s) and `CTTY CON' after to avoid output to screen.

See below to find how to chain/call another batch file.

Place the 'CTTY CON' first so you don't forget!

You need to be sure there are no interactive commands and no errors
stopping processing between them.

I used this in the 1980's-1990's to keep my kids from messing with the
text-based menues I setup for them.

[Lost the citation for this one]
(Note that these two commands must be used in a batch file because typing
`CTTY NUL' would transfer control away from your keyboard and monitor, thus
no input from the user would be recognised when typing `CTTY CON'
afterwards.)

https://everything2.com/title/CTTY

Another difference between using CTTY and conventional redirection is that
CTTY will redirect stderr as well as stdout.

If there is an error in the batch file that prevents the whole file from
being processed, then the CTTY CON may never be executed, rendering the
system unusable.

https://web.archive.org/web/20070503163833/http://www.chips.navy.mil/archives/96_oct/file14.htm

The usual CTTY NUL command won't work since it's only good in AUTOEXEC.BAT
files, and that's too late in the process. We needed an equivalent command
in the CONFIG.SYS file.

The syntax for our CONFIG.SYS file is: SHELL C:\COMMAND.COM NUL /E:1536 /P.

The first command in the AUTOEXEC.BAT file is: 'echo off'.

We placed CTTY CON as the second command in the AUTOEXEC.BAT file which
sets the I/O back to the keyboard and monitor.

CONFIG.SYS
REM  Set environment to 1536 and direct console I/O to NUL.
SHELL=C:\COMMAND.COM NUL /E:1536 /P

AUTOEXEC.BAT
echo off
REM  Re-establish normal console I/O (i.e. change NUL to CON)
CTTY CON

This is documented back to PC-DOS 2.0. Type COMMAND /? to see that the
second optional parameter to it is a device name, used for input and output.

https://www.robvanderwoude.com/command.php

COMMAND NUL /C some.bat
[??? COMMAND NUL /C call some.bat]
[It should stay NUL until the chain/call ends, then return to CON.]

COMMAND NUL /C ....
gives the same results as
CTTY NUL
....
CTTY CON

https://en.wikibooks.org/wiki/First_steps_towards_system_programming_under_MS-DOS_7/Internal_commands#3.07_CTTY_–_redirection_of_I/O_links

CTTY command affects only implicit I/O settings, but it doesn't affect
redirections, which are specified in command lines explicitly.

For example, let's consider the following piece of a batch file:

@ctty nul
copy /B Trial.dat Suit.dat
echo Press any key to exit > con
pause < con
ctty con

Here a message from the COPY command will not reach the screen, even if it
will be an error message. But the message "Press any key to exit" will be
shown, because it is directed to the CON device explicitly. The next PAUSE
command will work properly too, because its input is explicitly linked with
keyboard. This form of CTTY usage needs some caution, but opens attractive
opportunities to affect interaction with the user.

Note: Having been banned by CTTY NUL command, the STDERR messages can't be
redirected explicitly and are lost.


On Sat, Feb 26, 2022 at 10:10 AM <userbeit...@abwesend.de> wrote:

> On 26 Feb 2022, 02:54, Bret Johnson wrote:
> > I've tried creating an ECHO environment variable.  With older versions
> of DOS:
> >
> >    SET ECHO=ECHO OFF
> >
> > and with newer versions of DOS:
> >
> >    SET ECHO=@ECHO OFF
> >
> > then at the beginning of all batch files I put a:
> >
> >    %ECHO%
> >
> > That works with older versions of DOS but not newer versions.  With
> newer versions, it sees the "%" at the beginning of the line instead of the
> "@" and looks for an executable file called "@ECHO" instead of seeing the
> "@" as the "hide this line" character.
>
> > Anyway, any other ideas on how to resolve the ECHO/@ECHO issue?
>
> I don't think that this can be solved -- because there are so many
> different command interpreters out there, and every one acts at least a
> tiny little bit differently...
>
> I just tried "SET ECHO=@ECHO OFF" and "%ECHO%" in a batch file with 4DOS
> (a replacement for the COMMAND.COM command interpreter of any given DOS)
> and it worked.
>
> How about using 4DOS as a default SHELL, i.e. set SHELL= in CONFIG.SYS
> (you already rely on SET ECHO for your batch files...) and this will
> solve your issue on every DOS, regardless of the exact version.
>
> A.
>
>
> _______________________________________________
> Freedos-user mailing list
> Freedos-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-user
>
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to