I am running multiple perl scripts (about 2-5) within a ASP.net page using VB.net. The scripts are executing just fine. The script is returning the DNS name and other information of the UNIX server to ensure we have it configured correctly.
I need to output the Perl results to VB.net so I can show the results in the main page (and color code depending on success/failure).
Any suggestions?
EDIT: Showing my code
If rdoUnix.Checked Then
runUnixScript("testScript.pl", UNIXUSERNAME, UNIXPASSWORD)
End If
End If
End Sub
Public Sub runUnixScript(ByVal SCRIPT As String, ByVal UNIXUSERNAME As String, ByVal UNIXPASSWORD As String)
Dim COMPUTERNAME As String = FQDN.Text
Dim virtualFolder As String = "~/Scripts"
Dim physicalFolder As String = Server.MapPath(virtualFolder)
Dim processCmdFileTransfer As String = "/K C:\pscp.exe -pw " & UNIXPASSWORD & " " & physicalFolder & "\" & SCRIPT & " " & UNIXUSERNAME & "@" & COMPUTERNAME & ":" & SCRIPT
Dim processCmdFileActions As String = "-ssh -pw " & UNIXPASSWORD & " " & UNIXUSERNAME & "@" & COMPUTERNAME & "XX" & SCRIPT
' Transfers Script, Makes it executable, Runs Script and then deletes script
RunProcess("C:\Windows\System32\cmd.exe", processCmdFileTransfer, SCRIPT)
RunProcess("C:\plink.exe", processCmdFileActions, SCRIPT, " chmod u+x ./")
RunProcess("C:\plink.exe", processCmdFileActions, SCRIPT, " ./")
RunProcess("C:\plink.exe", processCmdFileActions, SCRIPT, " rm ./")
End Sub
Public Sub RunProcess(ByVal processPath As String, ByVal startInfo As String, ByVal script As String, Optional ByVal command As String = "")
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo = New ProcessStartInfo(processPath)
If (InStr(startInfo, "XX") > 0) And (command <> "") Then
startInfo = startInfo.Replace("XX", command)
End If
Proc.StartInfo.Arguments = startInfo
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Proc.WaitForExit()
End Sub