running shell script thru WEB page ....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting running shell script thru WEB page ....
# 1  
Old 07-20-2004
running shell script thru WEB page ....

....passing variable via list...


here 's the HTML code extract :

****************
<form method=post action=http://servername/cgi-bin/cgi-comptage_diff.ksh>
<table border...........>
.............. </table>
<table bgcolor=#FFFFFF width="980">
<td align=center width="250" bgcolor="#FFFFFF" height="90" bordercolor="#339933">
<select size=20 name=TOTO>
<option>APP101</option>
<option>APP102</option>>
.....
******************

whether i select APP101 or APP102 , i send "TOTO=APP101" when i only need "APP101" and second behind "APP101" , i catch a DOS carriage return that i don't need.

I'm running shell AIX.

Somebody can help me ?

thanks in advance

Christian
# 2  
Old 07-20-2004
I don't fully understand what you want.

Using the following html code (note - i'm using GET here instead of POST)
Code:
<html><head></head><body>
<form method="get" action="http://localhost/cgi-bin/foo.ksh">
<select size="20" name="TOTO">
<option>APP101</option>
<option>APP102</option>
<option>APP103</option>
<option>APP104</option>
</select>
<input type="submit">
</form>
</body></html>

and the following basic shell script
Code:
#!/bin/ksh

echo -e "Content-type: text/html\n\n"
echo "<html><head></head><body>"
echo $QUERY_STRING
echo "</body></html>"

exit 0

The correct value of "TOTO" gets passed across (e.g. TOTO=APP103, or whatever). Is this what you want? You can always then use sed, tr, cut and other tools to get the output as you want it. Just use '=' as the delimeter and take the first field.

I'd seriously consider writing the cgi in Perl anyway

Cheers
ZB
# 3  
Old 07-21-2004
Thanks for your help ,

YES it is what i want except that the information received in
QUERY_STRING is DOS format:

TOTO=APP101 is in reality : TOTO=APP101^M
when i use in vi.

Confirmed with the following script , i got 7 characters when i display the variable APP204

******************************
echo -e "Content-type: text/html\n\n"
echo "<html><head></head><body>"
echo $QUERY_STRING

typeset -R6 QUERY_STRING
echo $QUERY_STRING
echo $QUERY_STRING|wc -m
typeset -L6 QUERY_STRING
echo $QUERY_STRING
echo $QUERY_STRING|wc -m

echo "</body></html>"

exit 0
********************************
the problem is that i want to add a value to APP101 like APP101A ,

how can i delete the "^M" DOS carriage return ?

thanks
Christian
# 4  
Old 07-21-2004
Pipe QUERY_STRING through tr to remove the carriage return character ( ASCII octal 015)

e.g.

Code:
NO_CR=`echo $QUERY_STRING | tr -d '\015'`

Cheers
ZB
# 5  
Old 07-21-2004
MySQL

thanks for your help ,

to sum up :

if we use <form method="get" ....
...we pass QUERY_STRING variable in the good format ("TOTO=APP101")

in the shell script if we try to read the input variable :

read TOTO

we got nothing

but...
...if we use <form method="post" ....
...we pass nothing in QUERY_STRING variable

and in the shell script if we try to read the input variable :

read TOTO

we got "TOTO=APP101^M"

....for sure we will use the first solution with "get" and the QUERY_STRING !!

thanks again i get the solution and i understand it !!

Christian
# 6  
Old 07-21-2004
...the "return" of the carriage return........................


......running the shell script on AIX , ksh is treating
2 files like that :

diff $fic_tmp2 $fic_tmp4 > $fic_tmp5 2> /dev/null
echo "$(cat $fic_tmp5|grep \> |sed -e 's/\>//g')"

and got :

name1
name2
name3.........

but when running from the WEB :

the result is :

name1name2name3

Question :

how can i treat $fic_tmp5 to have the same display on the WEB ?

i hope that this time the "^M" is missing !!!!! maybe SED but i'm still searching !!!!

Christian
# 7  
Old 07-21-2004
...the "return" of the carriage return........................


......running the shell script on AIX , ksh is treating
2 files like that :

diff $fic_tmp2 $fic_tmp4 > $fic_tmp5 2> /dev/null
echo "$(cat $fic_tmp5|grep \> |sed -e 's/\>//g')"

and got :

name1
name2
name3.........

but when running from the WEB :

the result is :

name1name2name3

Question :

how can i treat $fic_tmp5 to have the same display on the WEB ?

i hope that this time the "^M" is missing !!!!! maybe SED but i'm still searching !!!!

Christian
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Refresh web page in bash script

hello, I am trying to refresh my web page which is created in bash script. I have a HTML page which when press a button calls a bash script. this bash script created the same page with dynamic data. When pressing the button I am calling to a function that set time out of 7 seconds and and after... (1 Reply)
Discussion started by: SH78
1 Replies

2. UNIX for Dummies Questions & Answers

How to switch the user before executing a shell script from web page??

hi, i want to execute a shell script as a different user. the flow is like this. there is a html web page from which i have to call a shell script. web server is apache. to call the shell script from html page, a perl script is required. so the html page calls the perl script and the perl... (2 Replies)
Discussion started by: Little
2 Replies

3. Shell Programming and Scripting

Random web page download wget script

Hi, I've been attempting to create a script that downloads web pages at random intervals to mimic typical user usage. However I'm struggling to link $url to the URL list and thus wget complains of a missing URL. Any ideas? Thanks #!/bin/sh #URL List url1="http://www.bbc.co.uk"... (14 Replies)
Discussion started by: shadyuk
14 Replies

4. AIX

How to Use a UNIX Shell Script to Create an HTML Web Page?

dear friends , in my work i have to monitor some system performance in hourly basis by runing some commands , for example (lpstat) to know that all the queue is ready how can i create webpage and connect it with the server (AIX operating system) and make this page refreshed every 10 second and... (12 Replies)
Discussion started by: rami abusweilei
12 Replies

5. HP-UX

Help running a unix script from a web page

First, let me state that I am completely out of my realm with this. I have a server running HPUX. I'm not even sure if this can be considered a UNIX question and for that let me apologize in advance. I need to create a web page where a client can input 2 variables (i.e. date and phone number).... (0 Replies)
Discussion started by: grinds
0 Replies

6. Shell Programming and Scripting

How to input a number in a web page and pass to a script?

I am working on an embedded linux router and trying to make a webpage where the user can input a desired number of CPE and have a script update that number on the router. I have a CLI where I can log in and type the following to change that number echo "20">/proc/net/dbrctl/maxcpe which then... (7 Replies)
Discussion started by: BobTheBulldog
7 Replies

7. Web Development

Call shell script from HTML page - without web server

Hi, I have html page in my unix machine(server), which I will open with firefox or mozilla available in unix machine. Firefox or mozilla will be opened using x windows. Since I have access to unix machien(like other users) and this HTML page is for user having access to Unix machine, I see no... (7 Replies)
Discussion started by: vamanu9
7 Replies

8. Shell Programming and Scripting

Perl script to copy contents of a web page

Hi All, Sorry to ask this question and i am not sure whether it is possible. please reply to my question. Thanks in advance. I need a perl script ( or any linux compatible scripts ) to copy the graphical contents of the webpage to a word pad. Say for example, i have a documentation site... (10 Replies)
Discussion started by: anand.linux1984
10 Replies

9. Shell Programming and Scripting

how to redirect to a web-page by shell script

Dear all, I am calling a korn shell script(CGI script) by a web-page. This shell script do some checking in a unix file and return true or false. Now within the same script, If it returns true then I want to redirect to another web-page stored in htdocs directory. Example: Login page sends a... (3 Replies)
Discussion started by: ravi18s
3 Replies

10. Shell Programming and Scripting

Executing shell program from a web page

Hi, I am looking for a cgi-script which runs a shell script from a web page. When I click "Run" from a web page it should run the shell commands in an textarea and results should get back to web page. Thanks Venkat (5 Replies)
Discussion started by: venkatritch
5 Replies
Login or Register to Ask a Question