Page 1 of 1

apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 6:46 pm
by solar3000
I have a script that's already running, we'll call it template1.cgi.

It takes parameters such as title, etc...in the form template1.cgi?title=My page&name=pair&etc...
That's fine.

Now I writing another script. And it doesn't matter what language. But for this example:

page.cgi
#!/usr/bin/perl
print "content-type: text/html\n\n";
@x = `/pathToScript/template1.cgi 'title=My Page&key=value, etc...' ` ;
print @x;

When page.cgi is run in the shell such as /bin/bash, I get a full page.
When page.cgi is called via a web browser and processed by apache, it will print out the template except that the parameters just disappear.

Any guesses?

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 6:51 pm
by solar3000
Again, it could be a different script, it is still the same problem. It could be bash:

page.cgi
#!/bin/sh
echo "content-type: text/html";
echo
echo
echo `/pathToScript/template1.cgi 'title=My Page&key=value, etc...' ` ;

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 7:00 pm
by DougieLawson
Install this: http://search.cpan.org/~szabgab/CGI-Sim ... /Simple.pm

Write your script like this:

Code: Select all

#!/usr/bin/perl

use CGI::Simple;
my $q = CGI::Simple->new;
print $q->header();
my $title = $q->param('title');
my $name = $q->param('name');

$q->print('<html><head><title>'.$title.'</title></head>');
$q->print('<body><h1>Hello '.$name.'<h1></body></html>')


Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 7:05 pm
by solar3000
No one understands me.

The script.cgi is already written. But in CGI.pm. And it works fine.

But I'm writing another script, just one line of code. It calls the script.cgi. So it would be a one line script that calls the script you just wrote.

My only guess is that its an apache security restriction.

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 7:23 pm
by Heater
If in doubt, do not use Apache or PHP or Perl or CGI anything.

That is a lash up of technology from the late 1990's.

What actually is it you want to achieve?

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 7:30 pm
by solar3000
What would you use?

I have stacks of scripts already working. I wrote them back when I was still alive. But I want to call them from within another script so I dont have to rewrite them.

Also, it seems it doesn't matter what script I use, bash, perl, python, NewReallyCoolLangage, etc...

My only guess is that it could be an apache config. I wouldn't even know what to put in a search engine because I'm too stoobid.

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 7:58 pm
by DougieLawson
solar3000 wrote:
Mon Oct 30, 2017 7:05 pm
No one understands me.
Because, you're still not clearly stating the nature of your problem.

CGI programs are nothing special, I find that using HTML METHOD=POST is a bunch easier than METHOD=GET because the params are read from STDIN not from int ARGV/char * ARGC[].

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 8:12 pm
by Heater
solar3000,
What would you use?
Now a days I do everything in Javascript. Using node.js on the server end. Perhaps with nginx directing traffic.

I did the whole Apache, PHP, CGI thing back in 1990 something and was horrified at what a horrible mess it was. I swore never to do web development again. Until I discovered node.js...
I have stacks of scripts already working. I wrote them back when I was still alive.
I'm sorry to hear you are no longer alive.

Some how I doubt it :)
But I want to call them from within another script so I dont have to rewrite them.
OK. Admittedly I have no idea.

If you have CGI scripts in language X that calls language Y, that calls language Z... I think you are on your own in the chaos.

As far as I recall you should be able to run the whole stack from the command line, giving the right parameters, and the result should be what you want in HTML.

Do check you have the right permissions on everything.

Re: apache wont: script to call script and pass params

Posted: Mon Oct 30, 2017 8:18 pm
by solar3000
OK. I'll look into this node.js thing.

I've been out of touch for about 10 years at least.


Wait a minute, drupal uses node.js. That's where I saw it, when updating drupal.