简体   繁体   English

VB6 +如何从VB6应用程序在Linux机器上执行脚本

[英]VB6 + how to exe script on linux machine from VB6 app

How can a VB6 application that runs on a Windows XP machine, run a script on a Linux machine (Redhat 5.3) via SSH? 在Windows XP计算机上运行的VB6应用程序如何通过SSH在Linux计算机(Redhat 5.3)上运行脚本?

VB application should take the following arguments VB应用程序应采用以下参数

  1. Linux login Linux登录
  2. Linux password Linux密码
  3. Script path 脚本路径

And then run the script path via SSH. 然后通过SSH运行脚本路径。

For example 例如

ARG1 Login –        root
ARG2 Password –     USA123
ARG3 Script path -  /var/tmp/task.pl 

VB6 will run the script /var/tmp/task.pl on the Linux machine. VB6将在Linux机器上运行脚本/var/tmp/task.pl

You can try using the "shell" function to create a command windows and then send ssh commands and parameters to it via the "sendKeys" function. 您可以尝试使用“外壳”功能创建命令窗口,然后通过“ sendKeys”功能向其发送ssh命令和参数。 However, this will be an error prone solution. 但是,这将是易于出错的解决方案。

If you want a more permanent fix, take a look at this VB Library for SSH manipulation . 如果您想获得更永久的修复,请查看此VB库以进行SSH操作 You may find it of use. 您可能会发现它的用途。 Here is a link to a sample project . 这是一个示例项目的链接。

EDIT: 编辑:

I don't have the VB6 IDE so I reused a VBScript file I had created earlier. 我没有VB6 IDE,所以我重用了之前创建的VBScript文件。 It can either be run as is or can be very easily converted to VB6 code. 它既可以按原样运行,也可以很容易地转换为VB6代码。

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\Windows\System32\telnet.exe"
WScript.Sleep(1000)
objShell.SendKeys "o telnet.example.com"
WScript.Sleep(1000)
objShell.SendKeys "{enter}"
WScript.Sleep(10000)
objShell.SendKeys "user"
WScript.Sleep(2000)
objShell.SendKeys "{enter}"
WScript.Sleep(1000)
objShell.SendKeys "pass"
WScript.Sleep(2000)
objShell.SendKeys "{enter}"
WScript.Sleep(1000)
objShell.SendKeys "./var/tmp/task.pl"
WScript.Sleep(1000)
objShell.SendKeys "{enter}"
WScript.Sleep(1000)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM