in reply to Re^7: Cannot access HTTP::Response content properly
in thread Cannot access HTTP::Response content properly
Here is the background info you requested. I am basically trying to call a Perl script from within a C program. However, I don't want to just make a system() call. I want to be able to capture the output (stdout) from the Perl script. If I run the Perl script on it's own, I get the output displayed to stdout. If I call it from the C program I do not. At first I thought this was a problem with my C program, but I am pretty sure it is not. Why? Because if I assign a random string (aka "Hello World") to a variable in that same Perl script and execute a print command from inside it, THEN my C program is able to capture the output from stdout. But if I use the "print $res->decode_content" command it does not. Just for clarification, here is a portion of the C program:
char command[] = "/home/user/scripts/PerlScript.pl"; . . fp = popen(command, "r"); buffer = (char *)malloc(sizeof(char) * bufSize); while( fgets(buffer, bufSize, fp) != NULL) fputs(buffer, stdout); pclose(fp); free(buffer);
The above program calls the Perl script I have written that is in question. Again, if I do the following it prints when called from the C program:
my $randomVar = "Hello World\n"; print $randomVar;
But if I do this, it will NOT print from the C program (unless I call the Perl script by itself from the command line):
my $res = $ua->get('http://SOMEURLHERE'); print $res->decoded_content;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Cannot access HTTP::Response content properly
by ikegami (Patriarch) on Nov 03, 2009 at 20:09 UTC | |
by URAvgDeveloper101 (Novice) on Nov 03, 2009 at 20:19 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 21:00 UTC | |
by URAvgDeveloper101 (Novice) on Nov 03, 2009 at 21:06 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 21:11 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 21:05 UTC | |
by URAvgDeveloper101 (Novice) on Nov 03, 2009 at 21:08 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 21:33 UTC |