Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

cgi script calling another cgi

syntax help and logic



1:13 am on Mar 4, 2009 (gmt 0)

5+ Year Member


I am calling 1 cgi script immediately upon executing another.
The first cgi is a forum script and the immediate one called is the captcha script to weed out bots...and spam.

The first script has a path to perl and then:

require "/usr/local/www/cgi-bin/cgi/captchatest.cgi";

which is the captcha script.
Is the above syntax the correct way to call it so that it branches out? I would like to set a variable back on the pc browsing the site / or set as cookie....and change the logic in the first script to something like...

if a variable is not set on remote pc..branch to captcha script....if it is set continue on.

I am looking for direction on how to do this....and if it's possible in an easy way.

I would then have to set the variable/cookie upon successfully keying in the captcha codes.

I have spent a couple hrs...googling it and am fumbling.



5:06 am on Mar 4, 2009 (gmt 0)

5+ Year Member

Is the above syntax the correct way to call it so that it branches out?

Don't really know what you mean by branch, but when you call a script using "require" it pretty much is the same as if the required script is part of the main program.

You can't set a cookie and then check it without reloading the browser. You can check for a cookie when the perl script runs and if your script doesn't find what it needs then do a captcha, something like:

if (no cookie) {
require "captchatest.gic";


8:08 am on Mar 4, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

the require [perldoc.perl.org] perl function includes a library file but doesn't necessarily "execute" anything.


9:49 pm on Mar 4, 2009 (gmt 0)

5+ Year Member

He was already using "require" to run the captcha script (see his example above) so it should work the same.

Featured Threads

Hot Threads This Week

Hot Threads This Month