Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
clanmills
- Posts: 2
- Joined: 24 Aug 2017 04:39
#1
Post
by clanmills » 24 Aug 2017 05:00
Folks
I'm writing a batch file to automate a build process. I want to do:
The code in batFile.bat is :
Code: Select all
ECHO Enter your choice:
ECHO 1. Clean All
ECHO 2. Generate XMPSDKToolkit Dynamic Win32
ECHO 3. Generate XMPSDKToolkit Static Win32
ECHO 4. Generate XMPSDKToolkit Dynamic x64
ECHO 5. Generate XMPSDKToolkit Static x64
ECHO 6. Generate All
ECHO
set /P choice=Enter your choice:
ECHO your choice is %choice%
set GENERATE_ALL=Off
set NEXT_LABEL=ok
IF "%choice%"=="1" GOTO CLEANALL
IF "%choice%"=="2" GOTO 32DLL
IF "%choice%"=="3" GOTO 32LIB
IF "%choice%"=="4" GOTO 64DLL
IF "%choice%"=="5" GOTO 64LIB
IF "%choice%"=="6" GOTO GENALL
ECHO Invalid Choice, Exiting
exit /B 0
It always drops out because %choice% is '5 ' (with a blank, and possibly \r\n)
I have a work-around using Cygwin:
Code: Select all
c:\cygwin64\bin\echo -n 5 | call batFile.bat
Is there a way in DOS to echo a 'raw string' to stdout?
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#2
Post
by dbenham » 24 Aug 2017 10:09
Simply remove the unwanted space before the pipe.
Also, you don't need CALL when you use a pipe.
Dave Benham
-
clanmills
- Posts: 2
- Joined: 24 Aug 2017 04:39
#3
Post
by clanmills » 24 Aug 2017 10:52
So obvious, Dave. Of course. Echo is a cmd.exe builtin and is already raw! So echo 5 |builder.bat is the raw string '5 ' Where as echo 5|builder.bat is the raw string '5'.
Thanks very much for your help. Very much appreciated.