[2005] using echo in a Process
Hi I need to do "echo y | P:\tool\plink.exe -l user001 -pw pass001 -ssh hx-devx4 sh Assrde1/apps/infra/script/who_is_in dv66pw" because plink ask me if I want to Store the host key and I want the process to answer y.
But if I do
Code:
Dim objProcessG As New System.Diagnostics.Process
objProcessG.StartInfo.FileName = "echo y | P:\tool\plink.exe "
objProcessG.StartInfo.Arguments = "-l user001 -pw pass001 -ssh hx-devx4 sh Assrde1/apps/infra/script/who_is_in dv66pw"
objProcessG.StartInfo.UseShellExecute = False
' Set our event handler to asynchronously read the sort output.
AddHandler objProcessG.OutputDataReceived, _
AddressOf SortOutputHandler
objProcessG.StartInfo.RedirectStandardInput = True
objProcessG.StartInfo.RedirectStandardOutput = True
objProcessG.StartInfo.CreateNoWindow = True
objProcessG.Start()
' Use a stream writer to synchronously write the sort input.
Dim sortStreamWriter As StreamWriter = objProcessG.StandardInput
' Start the asynchronous read of the sort output stream.
objProcessG.BeginOutputReadLine()
Dim inputText As String = String.Empty
Dim numInputLines As Integer = 0
sortStreamWriter.Close()
objProcessG.WaitForExit()
objProcessG.Close()
I got an error that the file don't exist.
Re: [2005] using echo in a Process
which file "dont exist" ? Which line throws the exception?
Re: [2005] using echo in a Process
You don't want Echo y as part of your filename. You want just the location of Plink, because that is the executable you are running. To output the letter Y, you will need to put this in the Standard Input after it prompts you.