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
 
Joined
Jul 22, 2016
Messages
6
Reaction score
6
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top