View Full Version : Unable to read last line from VBA plink stdout
Ankush
12-19-2016, 05:57 AM
Hi Friends,
Can you please check & help me.
When I try to read line by line from the stdout of plink, its always hangs to read the last line. Before last line, its show all lines in msgbox.
Code is in attached xls file.
Example.
=======
login as: Ankush
Last login: Mon Dec 19 19:51:53 2016 from IP
****USAGE WARNING****
Run help to get commands
hostname>
So message box is displaying the line till "Run help to get commands" , After that it hangs. No output and no further command execute.
Ankush
12-19-2016, 06:10 AM
17865
Ankush
12-19-2016, 06:11 AM
Code is attached in the xls file. So please help me, so that I can get all output and proceed to execute next steps.
Paul_Hossler
12-19-2016, 07:35 AM
I can't test it, but I believe that StdOut requires a Control-Z (EOF) from the keyboard to end the input
SO run the macro, enter the lines+<cr>, and then control-Z to end the input
Ankush
12-19-2016, 08:14 AM
Hi Paul,
Thanks for the information.
But I didn't get how to give +<cr> & control z to the end of input. pcmd is the varibale in the above code, sending as input.
So can you please edit with control z syntax. I will be very thankful to you.
Thanks!!
Harsh
Paul_Hossler
12-19-2016, 08:58 AM
I mis-understood a little. I thought you were entering the lines.
Sub main()
Dim Shell As Object
Dim password As String
password = InputBox("Enter password")
Set Shell = VBA.CreateObject("WScript.Shell")
pcmd = "C:\Ankush\plink.exe Ankush@142.22.34.54 -pw " + password
Set exec = Shell.exec(pcmd)
Set pout = exec.StdOut
If exec.Status = 0 Then
While Not pout.AtEndOfStream
pline = pout.ReadLine
MsgBox pline
Wend
MsgBox "Read Completed"
End If
Shell.Close
End Sub
My GUESS is that plink.exe needs to send a control-z (ascii 26) to close it's stdout, that's just a guess
Sorry
Ankush
12-19-2016, 09:17 AM
Any idea to fix this problem, as while reading last line, its hanging inside the loop. so not executing the further statement.
Thanks for your quick response on this.
Ankush
12-19-2016, 07:54 PM
Hi All,
Can you please check the above code and provide the way to read the last time from the plink stdout.
Thanks in advance for your support!!
Ankush
12-20-2016, 01:00 AM
anyone have any suggestion on this..
Ankush
12-20-2016, 10:09 PM
Issue is still there, can anyone help on this
Ankush
12-24-2016, 01:44 AM
?? Any suggestion.
Ankush
01-19-2017, 12:53 AM
Not sure, anyone use type of code in VB or not.. But issue still exists, appreciate if anyone can share something on this.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.