Seriously? test_process.pl is not a Perl function, and \"$myQuery\" isn't even close to valid Perl either.
my $output = `command`;
| [reply] [d/l] [select] |
Ikegami,
I am newbie to CGI and still not able to what am I doing wrong. I have a perl program that takes parameter and generates an array. Now I need to call this program from my .cgi file and retrieve the array. Since program cannot return(only subroutines can), how do I invoke this from CGI and fetch the array.
| [reply] |
Processes communicate via file handles, and file handles can only transmit bytes (not Perl arrays). You need to serialize the array somehow. I thought you already addressed that issue using Storable?
| [reply] |
Don't do that!
Your perl program should start with
#!/usr/bin/perl -T
and you should read perlsec and Simple Module Tutorial | [reply] [d/l] |
Monk - Yes my program starts with #!/usr/bin/perl -w. I am also able to capture the Query. But I need inputs on calling external programs.
Thanks
| [reply] |
#!/usr/bin/perl -T
called taint mode is different from
#!/usr/bin/perl -w
called warnings.
| [reply] [d/l] [select] |
When you point a browser at a CGI script, the script does not run as YOU, but as whatever user the web server is running as - usually 'nobody' or 'www-user' or 'apache'. This frequently causes permission problems, because the 'apache' user (for example) may not be able to read/write files in a particular directory that you can, etc.
So, if you have a script that YOU can run, but that fails to run under CGI, it's probably due to permission problems.
A better solution might be to rewrite your external program so that all the work is contained inside a subroutine, and put this inside a module. Then, your external program can 'use' this module, call the sub, and everything work the same as before, BUT, now the CGI can also 'use' the same module, and call the sub too (no external calls necessary). Since you want to "pass an array" this makes more sense (although if it's going to contain many elements, a REFERENCE to an array will be more efficient than the whole array).
If you're new to perl, I suggest you do a little more reading first - learn about subroutines, modules, references, etc. CGI scripts are hard to get right. There are MANY security issues involved. Read all the FAQs and tutorials on this site, just for starters. Good luck.
| [reply] |