Saturday, July 23, 2016

Running Unix (Putty) from VBA



Inder writes:

Hi All,

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

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



  • Kara Hewett


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



  • No comments:

    Post a Comment