批处理如何在setlocal enabledelayedexpansion 下输入叹号
现有本文内容,本人想用ftp读取本文快速登录指定目录,但现在ftp服务器密码有叹号“!”,在变量延时下不能输入“!”,请各位高手帮忙解决一下。1.txt中内容:beiji...
现有本文内容,本人想用ftp读取本文快速登录指定目录,但现在ftp服务器密码有叹号“!”,在变量延时下不能输入“!”,请各位高手帮忙解决一下。
1.txt中内容:beijing,open 192.168.1.1
hebei,open 192.168.2.2
jiangsu,open 192.168.3.3
1.bat中内容:
@echo off&setlocal enabledelayedexpansion
set /p var=(beijing/hebei/jiangsu):
for /f "tokens=1,2 delims=," %%i in (d:\1.txt) do (
set "aa=%%i"
set "bb=%%j"
echo !bb!>d:\!aa!.txt
echo guest>>d:\!aa!.txt
echo guest!>>d:\!aa!.txt
echo cd ftpdata/data>>d:\!aa!.txt
)
ftp -s:d:\!var!.txt 展开
1.txt中内容:beijing,open 192.168.1.1
hebei,open 192.168.2.2
jiangsu,open 192.168.3.3
1.bat中内容:
@echo off&setlocal enabledelayedexpansion
set /p var=(beijing/hebei/jiangsu):
for /f "tokens=1,2 delims=," %%i in (d:\1.txt) do (
set "aa=%%i"
set "bb=%%j"
echo !bb!>d:\!aa!.txt
echo guest>>d:\!aa!.txt
echo guest!>>d:\!aa!.txt
echo cd ftpdata/data>>d:\!aa!.txt
)
ftp -s:d:\!var!.txt 展开
1个回答
展开全部
你这代码根本不需要变量延迟啊。
@echo off
set /p var=(beijing/hebei/jiangsu):
for /f "tokens=1,2 delims=," %%i in (d:\1.txt) do (
(echo %%j
echo guest
echo guest!
echo cd ftpdata/data
)>d:\%%i.txt
)
ftp -s:d:\%var%.txt
如何非要启用变量延迟则在!前加两转义符号如:echo guest^^!>>d:\!aa!.txt
@echo off
set /p var=(beijing/hebei/jiangsu):
for /f "tokens=1,2 delims=," %%i in (d:\1.txt) do (
(echo %%j
echo guest
echo guest!
echo cd ftpdata/data
)>d:\%%i.txt
)
ftp -s:d:\%var%.txt
如何非要启用变量延迟则在!前加两转义符号如:echo guest^^!>>d:\!aa!.txt
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询