2011-09-14 19 views
0

配列の各要素に対して "configure call gcid splitArray(x)delete"をVBSCriptに渡そうとしています。代わりに、 "configure call gcid splitArray(x)delete"というように復帰する最後の要素まで "configure call 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> 

私は
ASD
ASD
ASD
ASD
ASD
ASD
悲しい
のtextarea call1でこれらの変数を使用する場合、私は結果のテキストエリアに次
のconfigureのコールを取得しますgcid asd
エラー:コマンドが不完全です。無効なコマンド名 "deleteconfigure"
deleteconfigureコールGCIDのASD エラー:無効なコマンド名 "deleteconfigure"
deleteconfigureコールGCID ASD
エラー:無効なコマンド名」
deleteconfigureコールGCID ASD
エラーを削除:のいずれかを予想deleteconfigure」
deleteconfigureコールGCID ASD は
エラー:無効なコマンド名 "deleteconfigure"
deleteconfigureコールGCIDのASD
エラー:無効なコマンド名 "deleteconfigure"
deleteconfigureコールGCID悲しい削除
エラー:無効なコマンド名「deleteconfigure」

答えて

2

私はあなたのcall2ではなくvbLfあなたが分割されているのvbCrLf Sが含まれていと思います。証拠:

>> a = Split(Join(Array("a", "b", "c"), vbCrLf), vbLf) 
>> For Each s In a 
>>  WScript.Echo "xxxx" & s & "yyyy" 
>> Next 
>> 
yyyya 
yyyyb 
xxxxcyyyy 
+0

+1これは良い推測です! –

+0

ありがとう、私はそれが最後にvbCrLfを追加していることを認識しませんでした.2行を変更しても動作します。 splitArray = Split(call2、vbCrLf、-1、0 shell.SendKeys "configure gcid"&splitArray(x)& "delete " & "{入る}" –

関連する問題