Sponsored Content
Full Discussion: Run ksh script from cgi
Top Forums UNIX for Dummies Questions & Answers Run ksh script from cgi Post 36317 by RTM on Tuesday 27th of May 2003 10:37:21 AM
Old 05-27-2003
In your html you simply place the script you are going to run:

Code:
<HTML>
<HEAD>
<TITLE>Problem-solver</TITLE>
</HEAD>
<BODY  TEXT vlink="black" link="blue" alink="white" >
<CENTER><STRONG>General Answer Generator</STRONG></CENTER>
<p>
Enter a short description of your computing problem in the box.  The program wil
l give back a suggestion on how to solve the problem.
<form name="myform" action=/cgi-bin/gag.cgi> 
<p>
<input type=text name="alertmsg" maxlength="40" size="80"></p>
<input type="submit" value="Submit your problem">
<input type="reset">


</form>
<HR size=2 noshade>
</BODY>
</HTML>

In this case it's gag.cgi which is in the cgi-bin directory.

Then you put your script (what ever language you want to use) in the cgi-bin directory (insure you chmod to allow execution). This is an example:

Code:
#!/bin/ksh
#
echo "Content-type: text/html"
echo
#
#
echo " <BODY>"
echo "<BODY  TEXT vlink=\"black\" link=\"blue\" alink=\"white\" >"
echo "<CENTER><STRONG>General Answer Generator</STRONG></CENTER>"
echo "<p>"
echo " "
echo "`/yourDIR/cgi-bin/getalert $QUERY_STRING'"
echo " "
echo "<p>"
echo "Enter a short description of your computing problem in the box.  The progr
am will give back a suggestion on how to solve the problem."
echo "<form name=\"myform\" >"
echo "<p>"
echo "<p><input type=text name="alertmsg" maxlength=\"40\" size=80> </p>"
echo "<input type=\"submit\" value=\"Submit your problem\">"
echo "<input type=\"reset\" >"
echo "<HR size=2 noshade>"
echo ""
echo " </BODY>"
echo "</NOFRAMES>"
exit

Code:
#!/bin/ksh
#
#
alertmsg="Wow, you stumped me.  Have you tried rebooting?"
alert1msg="Check the web documentation pages for information on the problem"
alert2msg="Check the set up of the computer"
alert3msg="Check for any network issues"
alert4msg="Check for any Change Controls that may have caused the problem"
alert5msg="Hmm, have you tried rebooting?"
#
alert1=`echo $1 | grep -ci unix`
alert2=`echo $1 | grep -ci not`
alert3=`echo $1 | grep -ci network`
alert4=`echo $1 | grep -ci change`
alert5=`echo $1 | grep -ci pc`
#
if [ alert1 -gt 0 ] ; then
        alertmsg=$alert1msg
fi
if [ alert2 -gt 0 ] ; then
        alertmsg=$alert2msg
fi
if [ alert3 -gt 0 ] ; then
        alertmsg=$alert3msg
fi
if [ alert4 -gt 0 ] ; then
        alertmsg="$alert4msg"
fi
if [ alert5 -gt 0 ] ; then
         alertmsg="$alert5msg"
fi
#
exit

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CGI passing arrays/hashes to another CGI script

If I have a Perl CGI script (script01), which fills an array(s) with information and outputs a HTML page with a link to another CGI page (script02); is there anyway to pass the array(s) from "script01" to "script02" when the page visitor clicks the link? Hope that makes sense! :) (2 Replies)
Discussion started by: WIntellect
2 Replies

2. Shell Programming and Scripting

Executing ksh script from cgi

Hi all, I'm developing a system which requires me to run a ksh script from within a cgi script. What sort of syntax will I need to do this, I'm sure it's simple but can't find out how anywhere! Thanks. (1 Reply)
Discussion started by: hodges
1 Replies

3. Shell Programming and Scripting

how to run cgi -script on Cygwin ?

All, I would like to run a cgi script in cygwin which i have installed in WinXP. My CYGWIN directory structure is /var/www/ drwxrwx---+ 2 user Users 0 Nov 23 16:24 cgi-bin drwxrwx---+ 3 user Users 0 Oct 22 17:21 htdocs drwxrwx---+ 3 user Users 0 Oct 22 17:22 icons and another... (1 Reply)
Discussion started by: jambesh
1 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. Web Development

Apache, cgi script run twice when ssl, once when not ssl

I have interesting problem. https:/host/some/x.cgi - this script has run twice when I call this url But http:/host/some/x.cgi work fine, only once. Output is text/plain. If I change output format to the Content-type text/html, then both urls works fine - executed only once. (2 Replies)
Discussion started by: kshji
2 Replies

6. Homework & Coursework Questions

Run Program from Bash CGI-Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is a problem I am having with my 2 semester senior project. I have a LAMP server running Ubuntu 9.10 with... (8 Replies)
Discussion started by: JMooney5115
8 Replies

7. Shell Programming and Scripting

Run script in a backgroun - ksh

i ran the below in ksh... nohup <script> & it is runnign in background. now how do i see if the above command is success... i also need to bring the command to foreground and view the run details. pls advise how to do that... (1 Reply)
Discussion started by: billpeter3010
1 Replies

8. UNIX for Beginners Questions & Answers

How to run script through CGI?

Hi I have written a script and I want it to be run from web with the help of CGI. can you please guide me . below script is working fine if run from backend but not sure how I should run through web. #!/bin/bash string1=look string2=0 string3=.sdn.dnb echo -n "enter... (3 Replies)
Discussion started by: scriptor
3 Replies

9. Shell Programming and Scripting

Help with copying from one drive to another with cgi & ksh script

Hi I was hoping some one could help me with a problem I have with a .cgi script I am running in the korn shell. I have created a web form that user fill out to gather information that I use a .cgi and sed script to translate into a xml file which is further processed by another program. All is... (6 Replies)
Discussion started by: Paul Walker
6 Replies

10. UNIX for Beginners Questions & Answers

How to convert my /bin/sh script with cgi and html to run it on browser!??

Hello, I want to run this script on my CentOS 6 via browser : ________________________________________________________________________________________________ #!/bin/sh echo Username? read MY_NAME echo Provisional file name? read MY_FILE echo File NAME you want to save? read MY_FILE2... (16 Replies)
Discussion started by: juta2020
16 Replies
SSH2_METHODS_NEGOTIATED(3)						 1						SSH2_METHODS_NEGOTIATED(3)

ssh2_methods_negotiated - Return list of negotiated methods

SYNOPSIS
array ssh2_methods_negotiated (resource $session) DESCRIPTION
Returns list of negotiated methods. PARAMETERS
o $session - An SSH connection link identifier, obtained from a call to ssh2_connect(3). RETURN VALUES
EXAMPLES
Example #1 Determining what methods were negotiated <?php $connection = ssh2_connect('shell.example.com', 22); $methods = ssh2_methods_negotiated($connection); echo "Encryption keys were negotiated using: {$methods['kex']} "; echo "Server identified using an {$methods['hostkey']} with "; echo "fingerprint: " . ssh2_fingerprint($connection) . " "; echo "Client to Server packets will use methods: "; echo " Crypt: {$methods['client_to_server']['crypt']} "; echo " Comp: {$methods['client_to_server']['comp']} "; echo " MAC: {$methods['client_to_server']['mac']} "; echo "Server to Client packets will use methods: "; echo " Crypt: {$methods['server_to_client']['crypt']} "; echo " Comp: {$methods['server_to_client']['comp']} "; echo " MAC: {$methods['server_to_client']['mac']} "; ?> SEE ALSO
ssh2_connect(3). PHP Documentation Group SSH2_METHODS_NEGOTIATED(3)
All times are GMT -4. The time now is 02:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy