Triggering my Unix script....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Triggering my Unix script....
# 1  
Old 08-16-2008
Data 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 solutionSmilie

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
# 2  
Old 08-16-2008
So you need a CGI with a form that allows your users to write a number, right?

Code:
#!/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
# 3  
Old 08-16-2008
Bug

Hi,

Many thanks for your quick response....Smilie

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..

CSmilierogram files/indigoperl/cgi/bin/

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

Thanks
Sha
# 4  
Old 08-16-2008
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.
# 5  
Old 08-16-2008
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)
Code:
# /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
Code:
# 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

Last edited by buffoonix; 08-16-2008 at 02:22 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Triggering a script using POSTFIX....

I have a mail server configured on my server (Postfix), I have a script which requires input to be provided to it. I would like to know if there is a possibility to trigger this script by sending mail to the server. This is what I am thinking: Once the mail arrives on server, the mail will... (6 Replies)
Discussion started by: davidbob
6 Replies

2. Shell Programming and Scripting

Triggering UNIX Script from a JAVA program

Hi I am trying to implement one program, where JAVA needs to trigger the backend UNIX script. Tried with options like String cmdArray = {"/bin/ksh","-c","/SCRIPT_ABSOLUTE_PATH/sampleScript.ksh /FILE_ABSOLUTE_PATH Test_File.dat TEST E SFTP"} When I trigger the script from front end with... (1 Reply)
Discussion started by: karumudi7
1 Replies

3. Shell Programming and Scripting

Triggering remote UNIX shell script from Remote desktop

I m trying to run a batch script in remote desktop which executes unix commands on the unix server...the problem is i wnt the output in HTML format.so in my batch script i m giving the cmd like ssh hostname path ksh HC_Report.ksh>out.html ...but it generates the HTML file in remote desktop .i... (2 Replies)
Discussion started by: navsan
2 Replies

4. UNIX for Dummies Questions & Answers

Unix coding for triggering informatica

Hi, I have very little knowledge with unix and pmcmd. I need help with a issue. I have to see whether a file has been dropped in a particular location/path. If the file dropped I have to check the last modified time, which should be greater than 8pmEST the prior day. If the file has been... (4 Replies)
Discussion started by: redwolves
4 Replies

5. Solaris

Triggering UNIX command from Web Browser

HI, I want to trigger a UNIX command from a web browser page. The web browser will have few steps which will generate the UNIX command and then it should connect to the UNIX box and fire that command. Here we are using Sun Solaris UNIX. Can you please suggest me how can i get... (6 Replies)
Discussion started by: dear_abhi2007
6 Replies

6. UNIX for Dummies Questions & Answers

Script triggering Korn shell, how-to stop it?

Script_A.sh has echo "In am in script A" ksh ## K-shell is invoked. Script B.sh ## which I am writing... ./script_A.sh echo "I am in script B" return 0 When I run: $> Script_B.sh $> I am in script A $> Basically, on calling Script_A.sh from within Script_B.sh I have the issue of... (2 Replies)
Discussion started by: baivab
2 Replies

7. Shell Programming and Scripting

Triggering a Script Recursively With Different Parameter and in Different Process

Hi Every One I have a Compilation Script name scomp which takes the Program name as the command line argument I have around 10000 Programs to compile while each program takes around 10 mins to compile i have written a Mass Compile script Scripts which takes the list of programs as input... (15 Replies)
Discussion started by: pbsrinivas
15 Replies

8. Windows & DOS: Issues & Discussions

Urgent Need for Assistance: Triggering Windows bat files from UNIX

Hello, Is there a way to trigger a Windows bat file or program on a different machine from a different UNIX server using KSC file? I hope you can assist me with this. Thanks! (0 Replies)
Discussion started by: punyenye
0 Replies

9. UNIX for Dummies Questions & Answers

triggering utility

gang, I have a need for a utility that will 'watch' a directory and when a file pops into it, it will run a script on the file. More specifically, it will pgp decrypt the file that pops into the directory. Our Security guys aren't comfortable with the 'normal' users on our system being able... (1 Reply)
Discussion started by: hedrict
1 Replies
Login or Register to Ask a Question