standard in/out from plink through cmd

Brokenac3

New member
Joined
Feb 7, 2012
Messages
1
Programming Experience
Beginner
Hello!

I'm having trouble with standard in/out with plink in VB, currently...


Dim p1 As New ProcessStartInfo
p1.RedirectStandardInput = True
p1.RedirectStandardOutput = True
p1.UseShellExecute = False 'required to redirect
p1.WindowStyle = ProcessWindowStyle.Hidden
p1.FileName = "C:\WINDOWS\system32\cmd.exe"

p1.ErrorDialog = False
p1.CreateNoWindow = True
p1.WindowStyle = ProcessWindowStyle.Hidden
p1.RedirectStandardError = True
p1.RedirectStandardInput = True
p1.RedirectStandardOutput = True
p1.StandardOutputEncoding = System.Text.Encoding.ASCII

Dim Plink As New Process

Plink.StartInfo = p1
Plink.Start()

Dim inputWriter As StreamWriter = Plink.StandardInput
Dim outputReader As StreamReader = Plink.StandardOutput
Dim errorReader As StreamReader = Plink.StandardError


inputWriter.WriteLine("plink -load sessionname")
Thread.Sleep(2000)
inputWriter.Flush()


Dim tempOut As String

While Not Plink.StandardOutput.EndOfStream

tempOut = Plink.StandardOutput.ReadToEnd

End While


but when i set tempout = standard output my code breaks



i need this to open plink to a stored session in putty through cmd, and send a set list of commands after the previous one is completed but it breaks as soon as i try to get the output into a string

can anyone help me?
 

Latest posts

Back
Top