我想在 Excel 中使用 VBA 在我的 linux 服务器上调用一个脚本。为此,我使用了路径中的本地 Putty 副本。
我已经成功编写了一个命令来创建一个腻子会话并登录到服务器,我只是不确定如何在 shell 中打开另一个命令后传递另一个命令。
有任何想法吗?
以下子例程有效,但在尝试第二个命令时会导致问题。
干杯
Sub test()
Dim putty As String
Dim strCommand As String
Dim strCommand1 As String
Dim User As String
Dim Pass As String
Dim Host As String
Dim File As String
Dim RemotePath As String
putty = """" & Range("E3").Text & "\Putty.exe"""
User = Range("E8").Text
Pass = Range("E9").Text
Host = Range("E7").Text
'File = """" & Range("E11").Text & """"
RemotePath = Range("E10").Text
strCommand = putty & " -l " & User & " -pw " & Pass & _
" " & File & " " & Host & ":" & RemotePath
'MsgBox strCommand
Shell strCommand, 1 ' vbNormalFocus '
Module2.WaitFor (5)
Shell "ls -l > shell.log", 1
End Sub