我想让VBSCript通过“配置调用gcid splitArray(x)delete”数组中的每个元素。相反,即时获取“配置调用gcid splitArray(x)”,直到最后一个将作为“配置调用gcid splitArray(x)删除”回滚的元素。
我是一些什么新的脚本,在此先感谢。添加额外的文本到数组元素的末尾
<head>
<title>Test</title>
<HTA:APPLICATION ID="Test"
APPLICATIONNAME="Test"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>
<script language="vbscript">
Sub ClearCalls
serv2 = editor.serv1.value
call2 = editor.call1.value
splitArray = Split(call2, chr(10), -1, 0)
set Shell = CreateObject("WScript.Shell")
shell.run "cmd.exe"
Delay 1
Shell.SendKeys "telnet -f c:\results.txt " & serv2 & ".com"
Shell.SendKeys "{ENTER}"
Delay 1
Shell.SendKeys "username"
Shell.SendKeys "{ENTER}"
Shell.SendKeys "password"
Shell.SendKeys "{ENTER}"
Shell.SendKeys "admin debugsonus"
Shell.SendKeys "{ENTER}"
For x = 0 To UBound(splitArray)
splitArray1 = "configure call gcid " & splitArray(x) & " delete"
Shell.SendKeys splitArray1
next
Shell.SendKeys "{ENTER}"
Delay 1
Shell.SendKeys "exit"
Shell.SendKeys "{ENTER}"
Delay 2
Shell.SendKeys "{ENTER}"
Shell.SendKeys "exit"
Shell.SendKeys "{ENTER}"
readfile
End Sub
Sub Delay(seconds)
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "ping -n " & (seconds + 1) & " 127.0.0.1", 0, True
Set wshShell = Nothing
End Sub
</script>
<script language="JScript" type="text/jscript">
<!--
function readFile()
{
var fso, fileHandle, contents, resultvar;
fso = new ActiveXObject("Scripting.FileSystemObject");
fileHandle = fso.OpenTextFile(document.editor.resultvar.value, 1);
contents = fileHandle.ReadAll();
if (contents)
document.all("results").value = contents;
fileHandle.close();
}
//-->
</script>
<body>
<form name="editor">
<table>
<tr>
<td align="right">Server Name:</td>
<td><input type="text" size="18" id="serv1"></td>
</tr>
<tr>
<td align="right" valign="top">Calls:</td>
<td><textarea size="18" id="call1" rows="10"></textarea></td>
</tr>
<td valign="bottom" align="left" colspan="2">
<button type="submit" name="run_button" onClick="ClearCalls">Clear Calls</button>
</td>
<tr>
<td align="right" valign="top">Results:</td>
<td><textarea cols="80" rows="20" name="results" id="results" rows="10"></textarea></td>
</tr>
</table>
<td><input type="hidden" name="resultvar" value="c:\results.txt"></td>
</body>
如果我在textarea的CALL1使用这些变量
ASD
ASD
ASD
ASD
ASD
ASD
伤心
我会得到的结果textarea的以下
配置呼叫gcid asd
错误:不完整的命令。预期之一:删除
deleteconfigure呼叫GCID ASD
错误:无效的命令名称 “deleteconfigure”
deleteconfigure呼叫GCID ASD 错误:无效的命令名称 “deleteconfigure”
deleteconfigure呼叫GCID ASD
错误:无效的命令名称“ deleteconfigure”
deleteconfigure呼叫GCID ASD
错误:无效的命令名称 “deleteconfigure”
deleteconfigure呼叫GCID ASD
错误:无效的命令名称 “deleteconfigure”
deleteconfigure呼叫GCID伤心删除
错误:无效的命令名称“deleteconfigure”
+1这是一个很好的猜测! –
感谢,我没有意识到它是添加vbCrLf到最后我改变了2行,它的工作原理 splitArray =拆分(call2,vbCrLf,-1,0 Shell.SendKeys“configure call gcid”&splitArray(x)&“delete “&”{ENTER}“ –