Triggering my Unix script....

Hi All,

i dont have any idea about perl scripting...

i need some suggestion so that i can put my effort to find out the solution:D

let me explain....one of my tedious task which will taken care by Unix shell script which i prepared.

its a kind of routine work that i am running the script and getting the output through mail....

what i want here is.....there should be a web screen where anyone can give the input (eg: 001245625 landline number) so that should trigger my unix scripts like parsing arguments and the output of my unix script should redirect to the same web screen where that should get populate...

Hope this can be done by perl and CGI .....sorry i dont have any idea how to do this....

can any one guide me...so that i can try..
Help would be much appreciated..

Thanks in advance.
Sha

So you need a CGI with a form that allows your users to write a number, right?

#!/usr/bin/perl -w

print "Content-Type: text/html\n\n";

print '
<form action=test.cgi method=get>
<input type="text" name="number"/>
<input type="submit" value="Submit" />
</form>'; 

my (undef, $number) = split("=", $ENV{'QUERY_STRING'});   
print $number . "\n";

name the script test.cgi

Hi,

Many thanks for your quick response....:slight_smile:

Now i have installed indigo perl in my PC ..with apache web server and CGI also...

let say..if i want to run the cgi program..

can you guide me how to run cgi scripts with perl..and...should i have to place the file in corresponding location..

C:program files/indigoperl/cgi/bin/

or is there any way that i can run in linux box.

Thanks
Sha

Try putting the script I gave you for now with that name test.cgi in cgi-bin folder, give it execution permissions (chmod 755 test.cgi in Linux) and try accessing it from the web.

Your CGI script will have to be executed by your web server.
You wrote you were using Apache.
So it depends how you configured your Apache.
I assume you haven't compiled a static Apache from the sources yourself
and mod_cgi gets loaded by default.
If I remember correctly you can query the httpd binary for what modules it would load with the current config.
(sorry, haven't got an Apache set up on my current surf box to confirm)
with something like (note, your path may vary)

# /usr/sbin/httpd -t -DDUMP_MODULES 2>&1 | grep cgi

Usually in the global section or within a vhost context of httpd.conf one would define a
ScriptAlias directory.
But it is also viable to set ExecCGI within a Directory context.
But the 1st being the more common method you will have to look up what path
your ScriptAlias points to.
(again, depending on your Unix/Linux the path to httpd.conf may deviate)
Try

# grep -i ^[^#]*scriptalias /etc/httpd/httpd.conf

The 2nd parameter to the ScriptAlias directive denotes the directory
where you must place your CGI scripts in.
The script doesn't necessarily have to be owned by the user that runs your Apache
(see what User is set to in the httpd.conf)
but it must be executable by this user (usually # chmod +x script.cgi will do.
But remeber, whatever the script will do must be permitted to the Apache user.
Then restart your web server (or send the parent httpd a SIGUSR1 or SIGHUP),
open a browser and point it to your CGI script in the URL of your ScriptAlias,
this time the URI path must be the first argument from the ScriptAlias directive,
often something like http://your.webserver.fqdn/cgi-bin/yourscript.cgi