Running unix(putty) commands from vba

Joined
Nov 3, 2015
Messages
1
Reaction score
0
Hi All,

Kindly help me in the below code. It is running but only when am swtiching between excel and putty server manully.

Sub Putty()

Dim TaskID As Long
Windows("auto.xlsb").Activate
Sheets("Sheet1").Select
Range("h15").Select

TaskID = Shell("C:\Program Files (x86)\Quest Software\PuTTY\PuTTY.exe duk2srv0256 -pw password", vbMaximizedFocus)

AppActivate TaskID, True

SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
wait
wait
SendKeys "sh /cm/dev/saswork/Inder/CV_Daily_Check/inder.sh"
SendKeys "{ENTER}", True

MsgBox "process completed"
Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

Public Sub wait()

Dim sttime, curtime
Dim tt As Integer
sttime = Timer
tt = 0
While tt < 1
curtime = Timer
tt = curtime - sttime
Wend

End Sub
 
cmd ="C:\MyUtilities\plink.exe -pw PASSWORD USERNAME@IPADDRESS cat /dataops/profits/name.csv"Set datafile = CreateObject("Scripting.FileSystemObject").CreateTextFile("c:\name.csv",True)Set WshShell = CreateObject("WScript.Shell")Set oExec = WshShell.Exec(cmd)DoWhile oExec.Status =0IfNot oExec.StdOut.AtEndOfStream Then datafile.WriteLine oExec.StdOut.Readall EndIfLoop datafile.Close
 
Back
Top