C# Execute Perl Script - Syntax issue? -
as title says, having issues executing particular perl script c# program. have done in past , within same program. however, particular script resulting in load of "invalid operation exception: no process associated object."
the troubled code snippet below. exceptions thrown @ "perl.startinfo = perlstartinfo;"
public void parsereviews(string asin) { string args = @"'c:\\users\\cody\\documents\\amazon-downloader-master\\extractamazonreviews-divlayout.pl '" + "'c:\\users\\cody\\documents\\amazon-downloader-master\\amazonreviews\\com\\'" + asin + "'\\ > c:\\reviews.csv'"; processstartinfo perlstartinfo = new processstartinfo(@"c:\perl\bin\perl.exe"); perlstartinfo.arguments = args; perlstartinfo.useshellexecute = false; perlstartinfo.redirectstandardoutput = false; perlstartinfo.redirectstandarderror = true; perlstartinfo.createnowindow = true; process perl = new process(); perl.startinfo = perlstartinfo; perl.start(); }
the perl script can found here below. can execute "downloadamazonreviews" without hitch using same code. extractamazonreviews gives me issue. https://github.com/aesuli/amazon-downloader
it executes fine same arguments cmd terminal. thinking doing wrong spaces , string literals cannot figure out. i've tried without ' literals , different combinations.
here test asin number if want give try: b00rrdtm1q
ok.. silly me. figured out.
apparently, "filepath" > "file"
not valid argument. had remove > "file"
then change:
perlstartinfo.redirectstandardoutput = false;
to
perlstartinfo.redirectstandardoutput = true;
and read output using std out.
perl.standardoutput.readtoend();
thanks suggestions guys.
Comments
Post a Comment