CGI: refresh page and timeout


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CGI: refresh page and timeout
# 1  
Old 03-01-2005
CGI: refresh page and timeout

Hi, I've been able to put together an HTML page that calls on a cgi program (via ksh) to do some server side processing, then send it back to the user's browser window. The script basically tails a log file and refreshes every # seconds (user chosen) by using the "refresh" meta tag (html).

My problem is, I want the script to be able to timeout after a certain amount of time but am not sure how to approach this. Since the meta tage causes the page to refresh automatically, I cannot use a loop to count for a timeout session. I was thinking of going with some sort of javascript (not too familiar with it) in order to take care of the refresh and timeout. Does anyone have any suggestions or ideas they can throw my way? I'd really appreciate any help that I can get on this. My code is below if anyone wants to make any suggestions (structural criticism is very welcome):

Code:
#!/bin/ksh

echo "Content-type: text/html"
echo
PATH=/usr/local/kccmds:$PATH

refresh=`echo $QUERY_STRING | cut -d"&" -f3 | cut -d"=" -f2 | cut -d"-" -f2`
echo "<HTML>
<HEAD>
<TITLE>`KCSUN Region Tails` Region Tail</TITLE> </HEAD>
<PRE>
<meta http-equiv="refresh" content="$refresh; URL=d3tail.cgi">
</PRE>
<BODY>

<BR>"
#
region=`echo $QUERY_STRING | cut -d"=" -f2 | cut -d"&" -f1`
tail1=`echo $QUERY_STRING | cut -d"&" -f2 | cut -d"=" -f2`
check=`echo $QUERY_STRING | cut -d"&" -f2 | cut -d"." -f2 `


if [ "$refresh" = "x" ]; then
   refresh_msg="page refresh has been deactivated."
else
   refresh_msg="which refreshes every $refresh seconds,"

fi

region_dsp=`echo $region`
typeset -u region_dsp

if [ "$check" = "err" ];
   then
      buffer="sys/"
      tail1="unikixmain.err"
elif
   [ "$check" = "log" ];
   then
      buffer="sys/"
      tail1="unikixmain.log"
else
   buffer=""
fi

case $tail1 in
   kc.sysout) msg="You are viewing d3tail, $refresh_msg"
   ;;
   kc.syslog) msg="You are viewing d3tail1, $refresh_msg"
   ;;
   unikixmain.err) msg="You are viewing d3tail2, $refresh_msg"
   ;;
   unikixmain.log) msg="You are viewing d3tail3, $refresh_msg"
   ;;
esac

. d3env$region
echo "<PRE>"
echo "<hr>"
echo "<center><h2>You are in MTP Region $region_dsp</h2></center>"
echo "<center><h4>$msg</h4></center>"
echo "<hr>"

echo "<form method="LINK" ACTION="cat-tail.cgi" target="_blank">"
echo "<INPUT TYPE=submit name="$region-$tail1" value="Display_entire_log">"
echo " "
tail -20 $d3/$buffer$tail1

echo "<br>"
echo "<br>"
echo "</form>"
echo "</PRE>"

echo " <BODY>"


Code:
<HTML>
<Head>
<title>SUN Tail/Reports Menu</title>
</Head>
<body bgcolor="#000099">

<center><table>
<form method="LINK" ACTION="SUN Reports Menu.html" target="_blank">
<INPUT TYPE=submit value="   Reports   ">
</form>
</table></center>

<center><table border="3">
<tr bgcolor="white">
<td>
<form method="get" action="http://kcsun.kirchman.com/cgi-bin/d3tail.cgi" target="MAIN">
<select name="region">
        <option value="a">Region A
        <option value="b">Region B 
        <option value="c">Region C 
        <option value="d">Region D
        <option selected value="e">Region E 
        <option value="f">Region F
        <option value="g">Region G 
        <option value="h">Region H 
        <option value="i">Region I 
        <option value="j">Region J 
        <option value="k">Region K 
        <option value="l">Region L 
        <option value="m">Region M 
        <option value="n">Region N 
        <option value="o">Region O 
        <option value="p">Region P 
        <option value="q">Region Q 
        <option value="r">Region R 
        <option value="s">Region S 
        <option value="t">Region T 
        <option value="u">Region U 
        <option value="v">Region V 
        <option value="w">Region W
        <option value="x">Region X 
        <option value="y">Region Y 
        <option value="z">Region Z 
</select>
</td>
</tr>


<tr bgcolor="white"><td><input type="radio" name="d3tail" checked="d3tail" value="kc.sysout">d3tail</td></tr>
<tr bgcolor="white"><td><input type="radio" name="d3tail" value="kc.syslog">d3tail1</td></tr>
<tr bgcolor="white"><td><input type="radio" name="d3tail" value="sys/unikixmain.err">d3tail2</td></tr>
<tr bgcolor="white"><td><input type="radio" name="d3tail" value="sys/unikixmain.log">d3tail3</td></tr>

<center><td><h4><font color="white">Refresh Rate</h4></td></center>

<tr bgcolor="white"><td><input type="radio" name="refresh" checked="None" value="refresh-x">STOP</td></tr>

<tr bgcolor="white"><td><input type="radio" name="refresh" checked="5 sec." value="refresh-5">5 sec.</td></tr>

<tr bgcolor="white"><td><input type="radio" name="refresh" value="refresh-15">15 sec.</td></tr>

<tr bgcolor="white"><td><input type="radio" name="refresh" value="refresh-30">30 sec.</td></tr>

<tr bgcolor="white"><td><input type="radio" name="refresh" value="refresh-60">60sec.</td></tr>

<tr bgcolor="#000066"><td><center><input type="submit" value="   Submit   "></center></td><tr>


</form>
</table>


</body>

</HTML>

Login or Register to Ask a Question

Previous Thread | Next Thread

9 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. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Web Development

CGI not working with httpd server on busybox 1.15.0 on ltib Linux 2.6.34 (404 page not found)

I have some industrial ARM linux board with 2.6.34 Linux on it with Busybox v1.15.0. The https.conf is located in /etc/ and contains: H:/root/web In the www directory I also have 'cgi-bin' folder with chmod 777 and in that folder a file called 'testcgi'. Now I start the server with... (1 Reply)
Discussion started by: Roboserg
1 Replies

5. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 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

cgi script to print all .png files on a single page

Hi guys I'm relativley new to Perl, and have not touched html before, im trying to write a cgi script that prints all images on a single html page from a given directory. Im using perl to gather stats, rrdtool to update and create graphs now i just need to print these graphs all onto 1 index.cgi... (3 Replies)
Discussion started by: jeffersno1
3 Replies

8. UNIX for Dummies Questions & Answers

Refresh ls list on screen (auto-refresh)?

I am looking for a way to issue a command or string of commands to repeatedly display new files that are written to the directory. I usually use ls -ltr to see the newest files at the bottom of the screen. I would like to automate this command to refresh what is displayed every second or so. Can... (3 Replies)
Discussion started by: skidude
3 Replies

9. 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
Login or Register to Ask a Question