China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 11:21
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Urgent help needed: how to output | as a symbol instead of a command View 888 Replies 3
Original Poster Posted 2007-02-01 01:34 ·  中国 重庆 合川区 电信
新手上路
Credits 8
Posts 4
Joined 2005-08-02 18:09
21-year member
UID 41290
Status Offline
I want to make a batch file output a format like this into a text file
00-5E-8A-EE-8D-0D=192.168.0.37|37-YZ

This is the batch file I made
ipconfig /all >e:\ipconfig.txt
find "Physical Address" e:\ipconfig.txt >e:\phyaddr.txt
for /f "skip=2 tokens=12" %%M in (e:\phyaddr.txt) do set Mac=%%M
;The problem is here
echo %Mac%=192.168.0.%1|%1-YZ >>c:\1.txt
The | in the middle is the same as the pipe command under DOS, so if I change it to
echo %Mac%=192.168.0.%1"|"%1-YZ >>c:\1.txt
the output format becomes

00-5E-8A-EE-8D-0D=192.168.0.37"|"37-YZ
Could one of the experts point me to a solution?

[ Last edited by kuzei on 2007-2-1 at 01:40 AM ]
Floor 2 Posted 2007-02-01 01:35 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  Write it as echo %Mac%=192.168.0.%1^|%1-YZ >>c:\1.txt。

[ Last edited by namejm on 2007-1-31 at 12:47 PM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2007-02-01 01:50 ·  中国 重庆 合川区 电信
新手上路
Credits 8
Posts 4
Joined 2005-08-02 18:09
21-year member
UID 41290
Status Offline
Originally posted by namejm at 2007-2-1 01:35:
  Write it as echo %Mac%=192.168.0.%1^|%1-YZ >>c:\1.txt。

[ Last edited by namejm on 2007-1-31 at 12:47 PM ]



Tested, it works~ many thanks
Could you also explain what the ^ symbol does?
Floor 4 Posted 2007-02-01 15:39 ·  中国 浙江 杭州 华数
初级用户
Credits 116
Posts 28
Joined 2007-01-03 05:21
19-year member
UID 75318
Gender Male
Status Offline
The ampersand (&), pipe (|), and parentheses ( ) are special characters that must be preceded by the escape character (^) or quotation marks when you pass them as arguments.

& | ( ) are all special characters. When these characters are passed as arguments, you must add the escape character ^ or put them in quotation marks.
Forum Jump: