Results 1 to 3 of 3

Thread: [2005] using echo in a Process

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    172

    [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.

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2005] using echo in a Process

    which file "dont exist" ? Which line throws the exception?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width