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

Batch files adding "1" to command

1,853 views
Skip to first unread message

Ray Greene

unread,
Oct 12, 2010, 4:24:57 PM10/12/10
to
I have a PC running XP SP3 which adds a "1" to the output of a batch
file when it runs e.g. a batch containing the following command:

ping 192.168.0.1 > c:\ping.txt

it outputs

ping 192.168.0.1 1> c:\ping.txt

at the command prompt. When the same command is run directly from the
command prompt it runs correctly. Another PC behaves as it should when
running the same batch file.

I understand that the "1" has something to do with debugging, but what
causes it to be inserted automatically when run from a batch file, and
how do I make it stop?

--
Ray Greene

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

01MDM

unread,
Oct 12, 2010, 5:07:58 PM10/12/10
to
> --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---

Use "@echo off" if you want to avoid an output of the service
information in the console

@echo off
ping 127.0.0.1 >ping.txt

Or shield command with "@"

@ping 127.0.0.1 >ping.txt

0 - standart input stream (STDIN)
1 - standart output stream (STDOUT)
2 - standart error stream (STDERR)

foxidrive

unread,
Oct 12, 2010, 6:42:32 PM10/12/10
to
On 13/10/2010 07:24, Ray Greene wrote:
> I have a PC running XP SP3 which adds a "1" to the output of a batch
> file when it runs e.g. a batch containing the following command:
>
> ping 192.168.0.1> c:\ping.txt


because of this behaviour, always add a space after a numeral when
redirecting to a file.

EG:

ping 192.168.0.1 > c:\ping.txt

--
Regards,
Mic

billious

unread,
Oct 12, 2010, 8:22:15 PM10/12/10
to

"Ray Greene" <r...@rhq.co.nz> wrote in message
news:n0h9b61ve7f5nobs8...@4ax.com...

Full redirection syntax is now n>whatever where n is a digit.

The simple ">" form is implicitly "1>" to redirect stdout and this is shown
as the reported command.

Stop it? Not possible.

Side-effect: a separator when a digit appears before a redirector is now
required whereas previously it was optional.


Ray Greene

unread,
Oct 13, 2010, 1:01:44 AM10/13/10
to

OK thanks. Any idea why the "1" appears on one PC but not another? The
one in question is XP SP3, the one where it doesn't happen has SP2. Is
it an SP3 thing?

Message has been deleted

billious

unread,
Oct 13, 2010, 2:30:18 AM10/13/10
to

"Ray Greene" <r...@rhq.co.nz> wrote in message
news:l9fab65oo6bvdteta...@4ax.com...

> On Wed, 13 Oct 2010 08:22:15 +0800, "billious"
[snip]

>
> OK thanks. Any idea why the "1" appears on one PC but not another? The
> one in question is XP SP3, the one where it doesn't happen has SP2. Is
> it an SP3 thing?
>
> --
> Ray Greene
>

None whatever.

AFAIAA, this has been the case on XP before even SP1 - perhaps even in
earlier NT versions.


Ted Davis

unread,
Oct 13, 2010, 10:57:26 AM10/13/10
to
On Wed, 13 Oct 2010 18:01:44 +1300, Ray Greene wrote:

> OK thanks. Any idea why the "1" appears on one PC but not another? The
> one in question is XP SP3, the one where it doesn't happen has SP2. Is
> it an SP3 thing?

CMD.EXE in XP is known to behave in ways that seem random: sometimes it
does one thing, sometimes it does another. The behavior seems to be
related to the amount of time Windows has been up and/or what other
programs have run. I had one case where the probability that a given
script would fail when called repeatedly depended on the length of the
base name of the script file as well as whether the machine had been
recently rebooted - the behavior also varied across different XP machines
(I wound up running the program on a Linux box [as a cron task] and
accessing the results through a web server).

--
Ted Davis (tda...@mst.edu)

Ray Greene

unread,
Oct 14, 2010, 12:30:23 AM10/14/10
to

Random behaviour - gotta love it...

0 new messages