需要在UNIX服务器中运行批处理脚本并通过vbscript显示输出

时间:2015-11-23 06:27:37

标签: unix vbscript putty

我目前正在开发新的VBScript以在UNIX服务器中执行Shell(通过Putty软件),

Set shell = WScript.CreateObject("WScript.Shell")
shell.Exec D:\Putty.exe hostname -l username -pw password 1.sh

我收到connection refused错误。

当我在没有我的脚本(1.sh

的情况下运行以下命令时
shell.Exec D:\Putty.exe hostname -l username -pw password

建立连接没有任何问题。

另外,我只是想提取输出,一旦提取,会话就会自动关闭。

1 个答案:

答案 0 :(得分:1)

这在putty.exe中无效。然而,Putty有一个专门的程序来做这些事情,它被称为plink.exe - 在那里你可以传递命令并按照你的预期读取输出,你的例子应该像你指定的那样工作。

PuTTY Link: command-line connection utility
Release 0.63
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw -serial
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)
  -sercfg configuration-string (e.g. 19200,8,n,1,X)
            Specify the serial configuration (serial only)