Problem chaining piped FIND commands in BTM

Nov 13, 2008
255
3
www.thedave.me
Hey... I'm feeling like I must be missing something obvious here.

TCC 18.00.32 x64 Windows 10 6.3.10586.

What I'm trying to do is determine if a particular IP route has a specific route, and if so, which one (essentially to determine which of two VPNs are connected and how they're routing IP traffic)

From the command line, I can do this:

route print | find "192.168.0.110" | find "192.168.10.1"
echo %?

I'll either get a 0 if the route exists, or a 1 if it doesn't. But when I throw this in a BTM, I don't get any output from the route command, and I always get %? == 0.

A single "| find" works, it's only when I chain two together that it fails.

I could re-implement the logic to actually parse the "route print" properly instead of blindly looking for a couple of specific IPs, but this is "good enough" because it's really just a pre-check, I will later verify that the remote resources are actually available, but these checks take 5-10 seconds to fail and I was hoping to dump an error more quickly.

(If it isn't clear, I need to find a route for a specific IP, and then determine which of two gateways I was assigned. Depending on the gateway that is available, I'll then proceed in different directions)

Any clues why I can't chain two piped "find" commands in a BTM, but I can at the command line?
 
May 20, 2008
11,285
95
Syracuse, NY, USA
In a simple test, I don't see a difference between the command line and a BTM file.
Code:
v:\> type routefind.btm
route print -4 | find "169.254" | find "169.254.1.2"
echo %?
route print -4 | find "169.254" | find "169.254.1.6"
echo %?

v:\> routefind.btm
  169.254.0.0  255.255.0.0  169.254.1.1  169.254.1.2  21
  169.254.1.2  255.255.255.255  On-link  169.254.1.2  276
  224.0.0.0  240.0.0.0  On-link  169.254.1.2  276
  255.255.255.255  255.255.255.255  On-link  169.254.1.2  276
0
1
 
May 20, 2008
11,285
95
Syracuse, NY, USA
And here, it's as you might expect:
Code:
v:\> route print -4 | find "169.254" > nul

v:\> echo %?
0

v:\> route print -4 | find "garbage" > nul

v:\> echo %?
1
 
Nov 13, 2008
255
3
www.thedave.me
Code:
[~\AppData\Local\Temp]route print -4 | find "127.0.0.0" | find "127.0.0.1"
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306

[~\AppData\Local\Temp]echo %?
0

[~\AppData\Local\Temp]route print -4 | find "127.0.0.0" | find "127.0.0.2"

[~\AppData\Local\Temp]echo %?
1


Code:
[~\AppData\Local\Temp]"%comspec" /c exit 75

[~\AppData\Local\Temp]test.btm
route print -4
echo 75
75
route print -4
echo 75
75

[~\AppData\Local\Temp]type test.btm
@ECHO ON
route print -4 | find "127.0.0.0" | find "127.0.0.1"
echo %?
route print -4 | find "127.0.0.0" | find "127.0.0.2"
echo %?
 
May 20, 2008
11,285
95
Syracuse, NY, USA
With your test.btm (exactly):
Code:
v:\> "%comspec" /c exit 75

v:\> test.btm
route print -4
  127.0.0.0  255.0.0.0  On-link  127.0.0.1  306
echo 0
0
route print -4
echo 1
1

I guess it's one for Rex to figure out. Does your TCSTART.BTM do anything that might be relevant? I'm on 32-bit Win 7
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Does Windows 10 have FINDSTR.EXE? When I replace "FIND" with "FINDSTR" (no other changes necessary) in your test BTM, I get exactly the same, correct, results. It's something to try.
 

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
You can use the in-process pipes as an option. And/or FFIND instead of find.
Code:
route print -4 |! ffind /vkm /t"127.0.0.0" |! ffind /vkm /t"127.0.0.1"
echo %?

You can use RegEx's to find the text in a single FFIND call too:
Code:
route print -4 |! ffind /vkm /e"127\.0\.0\.0.+127\.0\.0\.1"

-Scott
 
Similar threads
Thread starter Title Forum Replies Date
fishman@panix.com Problem with 27.15 Support 2
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
R Problem with @INT[ value] in V26 Support 9
M Selecting test "off by one" problem in Take command Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
K_Meinhard Small problem in german IDE 26 Support 3
B Problem with color in nested shells Support 1
Joe Caverly Problem creating and switching to a DESKTOP Support 9
vefatica Another popup problem Support 10
Alpengreis ffind dialog (/W) problem Support 4
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
A Problem with functions @int @decimal and identifying Powershell as a shell. Support 12
B IF command problem in tcexit.btm Support 9
fishman@panix.com Problem at Startup of TCC Support 3
P Problem with SFTP copies Support 7
P Problem with FTP copies Support 10
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
R Problem with %_do_loop in nested do loops Support 2
fishman@panix.com New Problem with later Windows 10 Support 10
Peter Murschall A little problem with LEAVE and COMMENT Support 5
M Handling of %~I problem Support 4
WinLanEm FOR problem Support 18
K Problem With SCRPUT /u Support 3
vefatica What's TCMD's problem with ^e[0m? Support 13
Peter Murschall IDE: RTL with non-English resources-problem is back in Build 28 Support 4
rps Regex problem: \xnn not recognized as a hex character Support 0
rps PRIORITY LOW problem Support 1
old coot Regex problem: \xnn not recognized as a hex character Support 12
vefatica Another problem with build 22. Support 3
Alpengreis [23.x] Download-Problem Support 2
S Problem with " Support 3
C Problem navigating forums Support 11
x13 Problem listing repository files using DIR http(s)://... Support 8
Joe Caverly Problem with TEE in v22 Support 2
Alpengreis Problem with thousands delimiter and colors Support 17
M Take Command 18, migrating to another machine, license problem. Support 1
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
rps How to? @search problem Support 2
WinLanEm @SELECT problem Support 6
T Fixed Problem with use of Batch parameters in the IDE Support 1
Oz Solomon Problem with "list" Support 14
S V21.24 theme problem Support 2
Alpengreis Problem if command prompt is not legacy Support 4
Alpengreis TCMD.INI: The "super hidden" problem ... Support 6
G Odd problem - screen brightness Support 4
rps V20 In-process pipes problem Support 8
Alpengreis Again theme problem [v20.0.21]? Support 11
WinLanEm INPUT problem Support 1
Craig Fitzgerald problem with executable extensons with TCC version 19.10.51 x64 Support 3

Similar threads