So I am attempting to call a perl script from C#/asp.net web form. However it isn't entirely calling it correctly and I have two examples

string fullPath = @"Z:\path\test.pl"; string arguments = arg1 + arg 2 Process myProcess = Process.Start(fullPath, arguments); myProcess.WaitForExit(999); if(!myProcess.HasExited) { myProcess.Kill(); throw new Exception("Timed out while running process"); }

Now the perl file I am trying to run accesses files and creates folders named after them. I have already ran this from the command prompt(Win 7/Strawberry Perl) with the same arguments just to double check that all the permissions are there and running perl test.pl works just as I expect it to. However, when I call the script from within asp.net a terminal does open but nothing happens. It just opens and closes, so I experimented by adding a sleep(xxx) to my test.pl and it actually affects when the terminal closes. So that tells me that asp.net is indeed opening a process and executing this perl script, but only the sleep command. However, when I changed the sleep from sleep(3) to sleep(10) I was actually able to see one of the print statements in the perl script print to the terminal for about a tenth of a second before the terminal closed. So I am not sure what is going on.

ProcessStartInfo perlStart = new ProcessStartInfo(@C:\Strawberry\perl\ +bin\perl.exe"); perlStart.Arguments = "Z:\path\test.pl" + argument1 + argument2; perlStart.UseShellExecute = false; perlStart.CreateNoWindow = true; Process perl = new Process(); perl.StartInfo = perlStart; perl.Start(); perl.WaitForExit();

Now this code is suppose to do the same thing, but the sleep commands have no effect on it whatsoever. The terminal barely opens before it closes. EDIT: Actually goofing around with it, it looks like it is is printing the good old file not found error with this one, it's just so fast. Looking for an asp.net process sleep function as we speak. So again, the perl file on it's own in the command prompt does everything flawlessly. sleep(xxx) commands with asp.net are actually being executed and under the right circumstances print statements are also being executed. However, under asp.net, new text files and folders are not being created. The purpose of this program is that I am converting my perl parser that handles text files as large as 30 GB into asp.net so that my tool has a web front end. However, asp.net can only handle files ~2 GB. I looked into creating a file splitter but from what I could tell, I would have used the same classes/methods used to open up the files and therefore would have run into the same 2 GB limit.

asp.net Process Class: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx asp.net ProcessStartInfo Class: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx

I should mention that having...

sleep(10) print "something";

...or...

sleep(5); print "something"; sleep(5);

...or...

print "something"; sleep(10);

...has no effect on the one print statement I can barely see for a split second.


In reply to Calling perl in C# by joemaniaci

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.