Board logo

标题: 用管道和SET给变量赋值,结果提示变量未定义 [打印本页]

作者: hello12588     时间: 2010-10-28 12:39    标题: 用管道和SET给变量赋值,结果提示变量未定义

有一文档1.txt 里面内容只有一个数字1,想用"echo 1.txt | set this="这个命令给变量this赋值,但结果提示变量this未定义
请教这是为什么呢?有没有其他方法实现我要的功能呢?
作者: hello12588     时间: 2010-10-28 12:47
还有,我想在纯DOS下运行,不知道SET有没有什么限制
作者: HAT     时间: 2010-10-28 13:46
不管你的DOS纯不纯,根本没有你这种赋值的方法。
作者: hello12588     时间: 2010-10-28 15:35
看来是我太天真啦,那我这样用吧
copy setthis.txt+1.txt setthis.bat
call setthis.bat
其中setthis.txt中写上set this=
这样就可以用文档里的数值给变量赋值了
作者: clinttt     时间: 2010-10-28 15:54
厉害!
作者: radem     时间: 2010-10-29 11:28
set this=<1.txt
作者: hello12588     时间: 2010-10-29 15:18
唉,不行,this是空的,没有赋到值1
作者: sfcctv     时间: 2010-11-3 21:27
可以用lmod试试。
作者: radem     时间: 2010-11-5 13:38
6楼改为:
set/p this=<1.txt
就行了