中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-09 18:02
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [求助]还是特殊符号的过滤问题,用批处理生成网页 查看 778 回复 4
楼 主 [求助]还是特殊符号的过滤问题,用批处理生成网页 发表于 2008-05-22 17:44 ·  中国 上海 东方有线
中级用户
★★
积分 321
发帖 135
注册 2007-02-04 04:48
19年会员
UID 78578
性别 男
状态 离线
我现在的脚本如下:


@echo off
setlocal

:::eg.:http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.6.1.xml&condition=null
set "serverIP=http://192.168.0.60:9080"
set "baseUrl=%serverIP%/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/"
set "urlSuffix=^&condition=null"

set "cache=b:"
set "template=B:\make_index\html1.txt"
set "htmlFilenam=%cache%\index.html"

type %template% >%htmlFilenam%
for /r %%i in (*.xml) do call:process %%i

echo ^</body^> >>%htmlFilenam%
echo ^</html^> >>%htmlFilenam%

goto:eof

:process
::::echo %1
echo fn %~n1%~x1
set "xml=%~n1%~x1"
set "url=%baseUrl%%xml%%urlSuffix%"
:::echo "url=%url%"
echo ^<a href="%url%"^>%url%^</a^>^<br/^> >>%htmlFilenam%

goto:eof



遇到的困难就是产生的index网页文件中的链接不对。

不明白为什么在地址部分的还有^符号,而显示部分正常(没有^符号)。

《a href=“地址部分”》显示部分《/a》。
<a href="http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/4.1.10.xml^&condition=null">http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.1.10.xml&condition=null</a><br/> 
2 发表于 2008-05-22 17:49 ·  中国 山东 淄博 联通
银牌会员
★★★
积分 1,604
发帖 646
注册 2008-04-13 23:39
18年会员
UID 115804
性别 男
状态 离线
批处理的瓶颈也在于此,特殊字符~
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
3 发表于 2008-05-22 19:38 ·  中国 湖北 武汉 联通
版主
★★★★★
积分 11,386
发帖 4,938
注册 2006-07-23 17:10
20年会员
UID 59080
状态 离线
@echo off
setlocal

:::eg.:http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.6.1.xml&condition=null
set "serverIP=http://192.168.0.60:9080"
set "baseUrl=%serverIP%/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/"
set "urlSuffix=^&condition=null"

set "cache=b:"
set "template=B:\make_index\html1.txt"
set "htmlFilenam=%cache%\index.html"

type %template% >%htmlFilenam%
for /r %%i in (*.xml) do call:process %%i

echo ^</body^> >>%htmlFilenam%
echo ^</html^> >>%htmlFilenam%

goto:eof

:process
::::echo %1
echo fn %~n1%~x1
set "xml=%~n1%~x1"
set "url=%baseUrl%%xml%%urlSuffix%"
:::echo "url=%url%"
echo ^<a href=^"%url%^"^>%url%^</a^>^<br/^> >>%htmlFilenam%

goto:eof


[ Last edited by lxmxn on 2008-5-22 at 07:42 PM ]
4 发表于 2008-05-23 09:04 ·  中国 北京 联通(数字北京大厦IDC机房)
中级用户
★★
积分 321
发帖 135
注册 2007-02-04 04:48
19年会员
UID 78578
性别 男
状态 离线
非常感谢!

不过还是没有明白原因,我再去查查资料。
5 发表于 2008-05-23 10:55 ·  中国 湖北 武汉 联通
版主
★★★★★
积分 11,386
发帖 4,938
注册 2006-07-23 17:10
20年会员
UID 59080
状态 离线
因为第一个 %url% 是包含在双引号内的,在双引号的作用下,里面的 ^ 被原样的保留下来,而不是作为转义字符,所以会出现这个问题。
论坛跳转: