Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion ECHO without terminating CRLF - was "Re: com1 input"
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Al Dunbar  
View profile  
 More options Feb 16 2002, 12:08 am
Newsgroups: microsoft.public.win2000.cmdprompt.admin
From: "Al Dunbar" <LuigiDun...@hotmail.com>
Date: Fri, 15 Feb 2002 22:05:18 -0700
Local: Sat, Feb 16 2002 12:05 am
Subject: ECHO without terminating CRLF - was "Re: com1 input"

"john miller" <j...@millertransportation.com> wrote in message

news:43ea01c1b558$aa1d7010$19ef2ecf@tkmsftngxa01...

> I have a device attached to COM1 which sends/recieves
> data. I have been able to send data using this:

> echo "command" > COM1

> How can I recieve the answer or result that the device is
> returning.  I would like for the for the data which is
> being transmitted from the device to go to a file.

In testing my previous reply to the above, I ran across a way to simulate an
ECHO without a terminating CRLF sequence using batch-only facilities. No
doubt others are aware of this, however, I have not seen it since I have
been following this newsgroup, so will post it here for the benefit of any
others who, like myself, did not know.

The command "echo.hello world" emits the string "hello world" followed by a
CRLF sequence. There are at least a couple of situations where this fact is
a nuisance:

    - displaying a minimalist progress bar.
    - sending arbitrary character strings to a serial device.
    - writing strings from separate commands that need to appear in the same
line in an output file.

The command that does this is:

    <nul (set/p anyvariable=string to emit)

The "<nul" pipes a nul response to the set/p command, which will cause the
variable used to remain unchanged. As usual with set/p, the string to the
right of the equal sign is displayed as a prompt with no CRLF.

Here is an example where this is used for a rudimentary progress bar:

    @echo off
    for /l %%A in (1,1,20) do (
        <nul (set/p z=%%A)
        >nul ping 127.0.0.1 -n 2
    )

And here is an example where info is written to a single line in a file from
multiple uses of the set/p command:

    <nul (set/p z=hello) >out.txt
    <nul (set/p z= world!) >>out.txt
    dir out.txt

The dir command should indicate the file size as 12 bytes: "hello world!".

The strings output need not be literal, and can originate from any source
capable of creating a variable, simply by including a variable reference in
the prompt string:

    <nul (set/p z=sec min hours: %time:~6,2% %time:~3,2% %time:~0,2%)

/Al


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google