How to pass arguments from a textbox in CGI to a shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to pass arguments from a textbox in CGI to a shell script?
# 1  
Old 05-19-2014
How to pass arguments from a textbox in CGI to a shell script?

Hello All,

Could you please help me to explain that how do I pass textboxes values while running a shell script which need some arguments while running it and should be invoked after the button click.


Here is an example.

Code:
The first CGI is:
#!/bin/ksh
echo "Content-Type: text/html"
echo
echo "<HTML>"
 echo "<HEAD>"
echo "<TITLE>Refresh status</TITLE>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
echo "<SCRIPT TYPE=\"text/javascript\">"
 echo "<!--"
 echo "window.focus();"
 echo "//-->"
 echo "</SCRIPT>"
 echo "</HEAD>"
 echo "<BODY  TEXT vlink="black" link="blue" alink="white" >"
 echo "<CENTER><STRONG>test status form</STRONG></CENTER>"
echo "<FORM METHOD=POST ACTION=output.cgi>"
echo "Number of days: <input type="text" name="days"><br>"
echo "Stage: <input type="text" name="stage"><br>"
echo "Project Name: <input type="text" name="project"><br><br>"
echo "<input type="submit" value="Press button Submit generate output">"
echo "</FORM>"
 echo "</BODY>"
 echo "</HTML>"

 
 
The second CGI is where script is being called:
#!/bin/bash
echo "Content-Type: text/html"
echo
echo "<HTML>"
 echo "<HEAD>"
echo "<TITLE>Refresh status OUTPUT</TITLE>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
echo "<SCRIPT TYPE=\"text/javascript\">"
 echo "<!--"
echo "window.focus();"
 echo "//-->"
 echo "</SCRIPT>"
ksh test2.ksh stage project days (Here only problem is occuring while passing the arguments which are being generated by user with help of 1st cgi)
 echo "</HEAD>"
 echo "<BODY>"
echo "Done"
echo "<FORM METHOD=POST ACTION=htm_check_final.html>"
echo "<input type="submit" value="result">"
echo "</FORM>"
 echo "</BODY>"
 echo "</HTML>"



Could you please help.



Thanks,
R. Singh
# 2  
Old 05-20-2014
Hello All,

Really sorry to bother you all, could you please guide on same.
I really tried hard to search it but couldn't find a solution for same.

Will be grateful to you.



Thanks,
R. Singh
# 3  
Old 05-20-2014
Bumping up the post wont help you to give fast replies and that's against the forum rules.
If you do need it urgently, post it under "Emergency UNIX and Linux Support"

Quote:
I really tried hard to search it but couldn't find a solution for same.
What you have tried? Could you please show?


Quote:
Could you please help me to explain that how do I pass textboxes values while running a shell script which need some arguments while running it and should be invoked after the button click.
Whats the output of the first script and in what way you want to use the arguments in the seconds script.
# 4  
Old 05-20-2014
Hello clx,

Sorry I was not having intention to bump up the posts. I have first cgi in which I have prepared a form and asking users for three values which user wil enter in a text box. Then I have second cgi in which I am calling UNIX script, now I want to pass these arguments to that unix script as follows.

Code:
/bin/ksh
echo "Content-Type: text/html"
echo
echo "<HTML>"
 echo "<HEAD>"
echo "<TITLE>test status</TITLE>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
echo "<SCRIPT TYPE=\"text/javascript\">"
 echo "<!--"
 echo "window.focus();"
 echo "//-->"
 echo "</SCRIPT>"
 echo "</HEAD>"
 echo "<BODY  TEXT vlink="black" link="blue" alink="white" >"
 echo "<CENTER><STRONG>Test status form</STRONG></CENTER>"
echo "Number of days: <input type="text" name="days"><br>"
echo "Stage: <input type="text" name="stage"><br>"
echo "Project Name: <input type="text" name="project"><br><br>"
echo "<input type="submit" value="Press button Submit generate output">"
echo "<FORM METHOD=POST ACTION=output.cgi>"
echo "</FORM>"
 echo "</BODY>"
 echo "</HTML>"

2nd cgi:
Code:
#!/bin/bash
echo "Content-Type: text/html"
echo
echo "<HTML>"
 echo "<HEAD>"
echo "<TITLE>Refresh status OUTPUT</TITLE>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
echo "<SCRIPT TYPE=\"text/javascript\">"
 echo "<!--"
echo "window.focus();"
 echo "//-->"
 echo "</SCRIPT>"
 echo "</HEAD>"
 echo "<BODY>"
ksh test2.ksh stage project days
echo "<FORM METHOD=POST ACTION=htm_check_final.html>"
echo "<input type="submit" value="result">"
echo "</FORM>"
 echo "</BODY>"
 echo "</HTML>"



kindly let me know if you have any queries.




Thanks,
R. Singh
# 5  
Old 05-20-2014
If I got you right,

Code:
ksh test2.ksh stage project days

Inside test2.ksh, You need to do something like

Code:
STAGE=$1
PROJECT=$2
DAYS=$3

Now, $STAGE, $PROJECT and $DAYS would contain the value stage, project and days respectively inside the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to pass arguments while running a Shell Script

Shell Script Gurus, I am writing a shell script which needs User ID's to pass as an Arguments in command line while executing. Can this be doable? I've never done this, If you give a sample script that would be helpful, Thanks. (1 Reply)
Discussion started by: shekar777
1 Replies

2. Shell Programming and Scripting

Pass Arguments to Command from Shell Script

Hi all, I am working on a project, in which I have to connect to Bluetooth low energy device. I am able to connect and do data transfer from command line. But I want to do from script Here is my script #!/bin/bash #sudo hcitool -i hci0 lescan sleep 1 sudo hcitool -i hci0 lecc --random... (8 Replies)
Discussion started by: nithin@embdes
8 Replies

3. Shell Programming and Scripting

Need to pass shell arguments into Nawk/awk

Hi, I am in critical need of help, Thanks a ton for your help. I need to know how to pass the shell argument into nawk code in AIX. so that my file gets passed into that awk script and it can execute it part. To be detail, i have more than 100 files and in those files a particular field... (6 Replies)
Discussion started by: Selva_2507
6 Replies

4. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

5. Shell Programming and Scripting

[C SHELL] How to pass dynamic number of arguments

I have a task. The scenario is like this. I have a operation program (OPR1) , whose function is to simply double the (single)value it receives as input. I have to write a script to operate the OPR1 and save its output in a file. Later, I have to modify the script so as to be able to operate ... (0 Replies)
Discussion started by: animesharma
0 Replies

6. Shell Programming and Scripting

How to pass data from server (CGI script) to client (html page)

Hi I know how to pass data from client side (html file) to server using CGI script (POST method). I also know how to re-create the html page from server side after receiving the data (using printf). However I want to write static pages on client side (only the structure), and only to pass... (0 Replies)
Discussion started by: naamabm
0 Replies

7. Shell Programming and Scripting

How to pass arguments to SQL file passed in shell script?

Hi, I am using SYBASE database. in my script i am connecting to DB via using isql. isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies

8. Shell Programming and Scripting

need help to pass arguments in script

Hi, I have a my script here-- print "The Perl Script does the User health check and system health check...\n"; print "---------------------------------------------------------------------\n"; # use strict; my($OS); $OS = $^O; # need to test @ARGV before GetOptions shifts it if (@ARGV... (1 Reply)
Discussion started by: namishtiwari
1 Replies

9. Shell Programming and Scripting

Need help to pass arguments to shell script

Hi, I have a shell script called ftp.sh which is running continously in background. I tried passing arguments to this script but it did not worked out. Below is ftp.sh script. Please help me case $param in start) sleep_func "300" echo "!ksh $scr_ddir/ftp.sh... (1 Reply)
Discussion started by: bhargav20
1 Replies

10. Shell Programming and Scripting

How to pass arguments to a function in a shell script?

Hi, I have two shell variables $t1 and $t2 which I need to pass to a function in a shell script. The function will do some computation with those two variables and echo the resultant. But I do not know how to pass teh arguments. The function written is f1() {...... ........ } What should... (3 Replies)
Discussion started by: preetikate
3 Replies
Login or Register to Ask a Question