in reply to Calling perl in C#

Are you Suffering from Buffering?

If there's no "\n" at the end of what you're printing, and you haven't messed with $|, there's a good chance that the issue with your screen output is simply that the output buffer isn't being flushed to the screen until the Perl script exits.

That could explain wonky output.

As for explaining away the fact that files and directories aren't getting created, that probably has more to do with the permissions under which your Perl script is being executed, while running as an external command within the .net framework. If your Perl script is executing commands that create directories and files, surely the return values of those commands would indicate failure if you check them, and if they do indicate failure, $! is going to give you some clues as to what's wrong. Make sure that all your system commands (open, close, etc.) are being checked for success, and upon failure, make sure to dump the results to a logfile. Or if you're unable to get a logfile to be written, dump errors to STDERR inside of a routine that awaits a "hit enter to continue" before proceeding, so you can see what's happening.

We'll have a hard time telling you for sure what's wrong without seeing the offending code, and without seeing the error messages it's generating. And if you're not testing for failure, you won't see the system call error messages either.


Dave

Replies are listed 'Best First'.
Re^2: Calling perl in C#
by joemaniaci (Sexton) on Apr 18, 2012 at 20:25 UTC

    So I was goofing around with my second example and I noticed there was some text but the terminal was closing so fast I couldn't tell. So I spent five minutes clicking my asp.net button to execute the perl script and then trying to capture a screenshot of the terminal being open and I finally got it.

    This

    perlStart.Arguments = "Z:\location\test.pl" + argument1 + argument2;

    Needs to be changed to this.

    perlStart.Arguments = "Z:\location\test.pl" + " " + argument1 + " " + argument2;

    It was looking for a perl file called Z:\location\test.plwhateverthefirstargumentwaswhateverthesecondargumentwas

    It now created the folders and works flawlessly.