如何使用QTP在cmd上的OpenSSH期间捕获命令响应

时间:2015-11-16 13:18:03

标签: vbscript cmd qtp openssh hp-uft

我正在通过cmd做openSSH来连接linux系统。我可以在cmd控制台上看到命令响应,但无法使用QTP捕获命令响应。我需要在运行时脚本中使用响应。我不想使用" GetVisibleText"方法

1 个答案:

答案 0 :(得分:0)

我从未参与过openSSH,但您可以尝试将cmd提示符的输出重定向到文本文件并读取文本文件的内容

示例:

set WshShell = CreateObject("WScript.Shell")
return = WshShell.Run("cmd /c java > ""C:\temp\aa.txt"" 2>&1 ")

Set fso  = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("C:\temp\aa.txt", 1)
If file.AtEndOfLine<> true Then
            text = file.ReadAll
            MsgBox text
        else
            MsgBox "file is empty"
End If
file.Close