jwang
Jul 28th, 2008, 12:15 PM
I have a VB.NET application that uses Process to call perl scripts to do telnet communication with remote machines. After I deploy it using ClickOnce, client machine can install and run the application but it seems the perl scripts won't work. (It works fine without using ClickOnce deployment) This function is called as child thread from main application. Not sure if this will impact.
I have ensured to add the perl scripts to project and set their property to "content". And I did verify that those scripts are in the deployed file list. I call them from the same directory as application executable.
Here is the code:
Dim p As New Process
Dim sr As StreamReader
Dim sw As StreamWriter
Dim psi As New ProcessStartInfo(PerlExePath)
'Construct full path of the script called
myRemoteScriptPath = AppPath & "\" & myRemoteScriptName
psi.UseShellExecute = False 'Since we are redirecting to a stream this must be false
psi.RedirectStandardInput = True 'True enables us to send commands through a stream
psi.RedirectStandardOutput = True 'True enables us to capture data through a stream
psi.CreateNoWindow = True 'Prevents a DOS box to appear when running.
psi.Arguments = myRemoteScriptPath & " " & myRemoteIp 'Arguments to be used Perl Script Path & IPAddress
p.StartInfo = psi 'Associate the Process to the Process Info Object
p.Start() 'Start the Process: This runs the script
sw = p.StandardInput 'Set the Stream Writer to the process standard input
sr = p.StandardOutput 'Set the Stream reader to the process standard ouput
sw.AutoFlush = True
'System.Threading.Thread.Sleep(3000)
sw.Flush() 'Force a flush of the stream
sw.Close() 'Close the Sream Writer object prior to trying to read
myCmdResponse = sr.ReadToEnd 'Read the entire Stream into a string variable
Any help will be greatly appreciated.
Jerry
I have ensured to add the perl scripts to project and set their property to "content". And I did verify that those scripts are in the deployed file list. I call them from the same directory as application executable.
Here is the code:
Dim p As New Process
Dim sr As StreamReader
Dim sw As StreamWriter
Dim psi As New ProcessStartInfo(PerlExePath)
'Construct full path of the script called
myRemoteScriptPath = AppPath & "\" & myRemoteScriptName
psi.UseShellExecute = False 'Since we are redirecting to a stream this must be false
psi.RedirectStandardInput = True 'True enables us to send commands through a stream
psi.RedirectStandardOutput = True 'True enables us to capture data through a stream
psi.CreateNoWindow = True 'Prevents a DOS box to appear when running.
psi.Arguments = myRemoteScriptPath & " " & myRemoteIp 'Arguments to be used Perl Script Path & IPAddress
p.StartInfo = psi 'Associate the Process to the Process Info Object
p.Start() 'Start the Process: This runs the script
sw = p.StandardInput 'Set the Stream Writer to the process standard input
sr = p.StandardOutput 'Set the Stream reader to the process standard ouput
sw.AutoFlush = True
'System.Threading.Thread.Sleep(3000)
sw.Flush() 'Force a flush of the stream
sw.Close() 'Close the Sream Writer object prior to trying to read
myCmdResponse = sr.ReadToEnd 'Read the entire Stream into a string variable
Any help will be greatly appreciated.
Jerry