Home / Microsoft / Microsoft Windows / Windows NT/2000 / echo command return code
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: echo command return code  (Read 879 times)
TJ-III
Topic Starter
Newbie



Posts: 2

Experience: Beginner
OS: Unknown

« on: May 17, 2011, 09:24:02 AM »

1. Does the echo command return an error/exit code?
2. Is there any documentation anywhere that describes the return codes from echo?
3. Does an error from a pipe redirection of echo's output return an error code?
4. Is there any documentation anywhere that describes the return codes from pipe redirection?

Any help, suggestions, or pointers to reference material accepted with thanks.
IP logged
Geek-9pm
Sage



Thanked: 373
Posts: 8,925

Computer: Specs
Experience: Expert
OS: Windows XP


Geek After Dark

Geek 9pm blog
« Reply #1 on: May 18, 2011, 10:55:56 PM »

You need to explain what you want.
The 'echo' feature is part of the script used by the command processor. It is not a function or procedure that called by a program.
Have you read this?
http://www.computerhope.com/xdoseror.htm
IP logged

Salmon Trout
Sage



Thanked: 546
Posts: 7,948

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #2 on: May 19, 2011, 12:38:31 AM »

As Geek says, it would be interesting to know what you are aiming for.

Errorlevels are a bit of a mess. This batch shows what I mean.

Code: [Select]
@echo off
color 00
echo bad:   %errorlevel%
ver >nul
echo ok:    %errorlevel%
fc/? >nul
echo weird: %errorlevel%
set/? >nul
echo ret:   %errorlevel%
(set foo=)
echo ret:   %errorlevel%
rem Did not reset the errorlevel?
set foo >nul
echo ret:   %errorlevel%
rem So why did this one set the errorlevel?
echo hello | find "egg
echo ret:   %errorlevel%

Output (Win 7 64 bit SP1)

Code: [Select]
bad:   1
ok:    0
weird: -1
ret:   -1
ret:   -1
Environment variable foo  not defined
ret:   1
FIND: Parameter format not correct
ret:   2







« Last Edit: May 19, 2011, 01:14:07 AM by Salmon Trout » IP logged


Proud to be European
Salmon Trout
Sage



Thanked: 546
Posts: 7,948

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #3 on: May 19, 2011, 02:27:52 AM »

The example with FIND I showed above is with a malformed (deliberately wrong) FIND syntax (missing quote after search string). The errorlevel (2) is that set by FIND. Otherwise it would have been 0 (string found) or 1 (string not found).
IP logged


Proud to be European
Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft Windows / Windows NT/2000 / echo command return code « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.122 seconds with 21 queries.