Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: echo command return code  (Read 11418 times)

0 Members and 1 Guest are viewing this topic.

TJ-III

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    echo command return code
    « 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.

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1003
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows XP
    Re: echo command return code
    « 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

    Salmon Trout



      Genius

      Thanked: 966
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Other
    Re: echo command return code
    « 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 »

    Salmon Trout



      Genius

      Thanked: 966
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Other
    Re: echo command return code
    « 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).