我正在尝试从用户输入获取匹配,即201到我在POP1.txt中的变量中使用的服务器名称之一
POP1包含一个包含换行符的列表,例如
echo.%%a | findstr C:\"%portal%">nul && (
在CASE_DC1中我使用for语句,该语句适用于略有不同的用例,但现在我尝试将服务器名称过滤为用户输入。
例如,如果用户输入101,我希望for语句只打开与gui-server101-pop1的putty连接,而不必为每个语句创建单独的case语句。
我认为问题在于我如何在
中调用%% a set PATH=C:\Program Files (x86)\PuTTY\;%PATH%
@echo off & setlocal DisableDelayedExpansion
Title %~n0
Mode 60,5 & Color 17
set /p usr="Enter Username : "
Call:InputPassword "Enter Password " pwd
setlocal EnableDelayedExpansion
set /p portal="Select the portal (101, 201, 301): "
set /p DC="Move to a Data Centre (Type DC1 / DC2): "
2>NUL Call:CASE_%DC%
If ERRORLEVEL 1 Call :DEFAULT_CASE
EXIT /B
::***********************************
:InputPassword
Cls
echo Username: %usr%
echo.
set "psCommand=powershell -Command "$pword = read-host '%1' -AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set %2=%%p
)
goto :eof
::***********************************
::***********************************
:CASE_dc1 or CASE_Dc1 or CASE_DC1
for /f "tokens=*" %%a in (POP1.txt) do (
echo.%%a | findstr /c:"%portal%">nul && (
start putty -ssh %%a -l %usr% -pw %pwd% -m ENABLE.txt -t
)
|| (
echo.Not Found "%portal%"
)
)
for /f "tokens=*" %%a in (POP2.txt) do (
echo.%%a | findstr /c:"%portal%">nul && (
start putty -ssh %%a -l %usr% -pw %pwd% -m DISABLE.txt -t
)
|| (
echo.Not Found "%portal%"
)
)
goto END_CASE
:CASE_dc2 or CASE_Dc2 or CASE_DC2
for /f "tokens=*" %%a in (POP1.txt) do (
echo.%%a | findstr /c:"%portal%">nul && (
start putty -ssh %%a -l %usr% -pw %pwd% -m DISABLE.txt -t
)
|| (
echo.Not Found "%portal%"
)
)
for /f "tokens=*" %%a in (POP2.txt) do (
echo.%%a | findstr /c:"%portal%">nul && (
start putty -ssh %%a -l %usr% -pw %pwd% -m ENABLE.txt -t
)
|| (
echo.Not Found "%portal%"
)
)
goto END_CASE
:DEFAULT_CASE
echo Not a valid option "%DC%" (DC1 / DC2)
VER > NUL
set /p DC="Choose a Data Centre (Type DC1 / DC2): "
2>NUL Call:CASE_%DC%
If ERRORLEVEL 1 Call :DEFAULT_CASE
:END_CASE
VER > NUL
goto :eof
::***********************************
由于cmd提示测试返回%portal%但不是%% a
的值function stripeTokenHandler(token) {
// Insert the token ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
// Submit the form
form.submit();
}
由于
答案 0 :(得分:0)
解决方案被证明是单行声明,因为将它放在几行上并不起作用。即。
echo.%%a | findstr /c:"%portal%">nul && ( start putty -ssh %%a -l %usr -pw %pwd%) || ( echo.NotFound)