AnsweredAssumed Answered

Attempting to login to a cvs server using VB.net System.Diagnostics.Process

Question asked by bem on Aug 21, 2016
Latest reply on Aug 22, 2016 by Patrick.Cashman

Hello There,

I realize that this question is not specifically about Mentor tools however it is concerning our Mentor design environment.

I am attempting to develop a VB studio 2015 application that needs to interface (use) the cvs.exe (from CVSNT) command, but first I need to login to the server. I searched and I cannot seem to find an solution.

I can execute the command using the process class, and I see the first response from the command .....

Logging in to :pserver:xxxxx@xxxxxxxx.com:2401:/opt/xxxxxx/xxxxxRep

However I do not see the line prompt (which I think goes to errout)

CVS password:

I enter the password anyways but it just seems to hang.

Any help on how to interact with a command that is asking for a password will be appreciated.

Thanks

Brian

The code that I am attempting to use is....

 

----------------------------------------------------------------------------------------------

' Example From
' https://pradeep1210.wordpress.com/2010/02/04/launching-and-controlling-external-applications-from-vb-net-application/

Public Class Form1
  
Private WithEvents MyProcess As Process
  
Private Delegate Sub AppendOutputTextDelegate(ByVal text As String)


  
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
Me.AcceptButton = ExecuteButton
  MyProcess
= New Process
  
With MyProcess.StartInfo
  
'.FileName = "CMD.EXE"
  
.FileName = "C:\Program Files (x86)\cvsnt\cvs.exe"
  
.Arguments = "login xxxxxxx"

  
.UseShellExecute = False
  
.CreateNoWindow = True
  
.RedirectStandardInput = True
  
.RedirectStandardOutput = True
  
.RedirectStandardError = True
  
End With
  MyProcess
.Start()

  MyProcess
.BeginErrorReadLine()
  MyProcess
.BeginOutputReadLine()
  AppendOutputText
("Process Started at: " & MyProcess.StartTime.ToString)
  
End Sub

  
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  MyProcess
.StandardInput.WriteLine("EXIT") 'send an EXIT command to the Command Prompt
  MyProcess
.StandardInput.Flush()
  MyProcess
.Close()
  
End Sub

  
Private Sub MyProcess_ErrorDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.ErrorDataReceived
  System
.Diagnostics.Debug.WriteLine("ERROR OUT: " & e.Data)
  AppendOutputText
(vbCrLf & "Error: " & e.Data)
  
End Sub

  
Private Sub MyProcess_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.OutputDataReceived
  System
.Diagnostics.Debug.WriteLine("STD OUT: " & e.Data)
  AppendOutputText
(vbCrLf & e.Data)
  
End Sub

  
Private Sub ExecuteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExecuteButton.Click
  MyProcess
.StandardInput.WriteLine(InputTextBox.Text)
  MyProcess
.StandardInput.Flush()
  InputTextBox
.Text = ""
  
End Sub

  
Private Sub AppendOutputText(ByVal text As String)
  
If OutputTextBox.InvokeRequired Then
  
Dim myDelegate As New AppendOutputTextDelegate(AddressOf AppendOutputText)
  
Me.Invoke(myDelegate, text)
  
Else
  OutputTextBox
.AppendText(text)
  
End If
  
End Sub
End Class

Outcomes