I have a c# service that needs to call a perl script. Right now I have the perl script on my desktop and just reference the complete path of the desktop. Is it possible to add the perl script to the c# project and have it build to the same directory as the .exe that is generated after building? That way the file can be referenced from the current path. Code is below. Also the perl script uses sensitive information that I don't want on the script, would the best way to do this be passing the sensitive information as a parameter through c#?
Thanks,
ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"C:\strawberry\perl\bin\perl.exe"); perlStartInfo.RedirectStandardInput = true; perlStartInfo.UseShellExecute = false; perlStartInfo.CreateNoWindow = true; Process perl = new Process(); perl.StartInfo = perlStartInfo; perl.Start();
byte[] byteArray = Encoding.ASCII.GetBytes(Properties.Resources.TransferChange);
using (MemoryStream stream = new MemoryStream(byteArray))
{
stream.CopyTo(perl.StandardInput.BaseStream);
// this will cause perl to execute the script
perl.StandardInput.Close();
}
perl.Start();
perl.WaitForExit();
string output = perl.StandardOutput.ReadToEnd();
I added perl.Start(); to the code. I get all the way to perl.WaitForExit(); but it just hangs there. Any idea?