The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
refresh user profile dhinge UNIX for Dummies Questions & Answers 1 04-15-2008 02:46 PM
Refresh ls list on screen (auto-refresh)? skidude UNIX for Dummies Questions & Answers 3 11-13-2007 05:00 PM
Refresh window? JimmyFo AIX 0 08-25-2005 12:33 AM
How to increase refresh rate armen Linux 6 06-11-2005 08:57 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-01-2005
man man is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 13
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>
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0