cgi

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Date: Thu, 1 Apr 1999 00:53:32 +0000
Subject: Re: Shell script help
From: Cameron Simpson <cs@zip.com.au>

On 1 Apr 1999, in message <Pine.LNX.4.02.9904010114390.17032-100000@possum.os2.ami.com.au>
  John Summerfield <summer@OS2.ami.com.au> wrote:
| > > and quits. I want the second script to run asynchronously -but- to continue
| > > running when the cgi script
| > > quits. I thought of using "at" but is there a pure bash solution?
| > start your second script with:
| > 	command-to-start-script &
| > or
| > 	nohup  command-to-start-script &
| The at command is probably better though. I assume you want the second
| script to run asynchronously because it's longer running or more demanding.
| You probably don't want it being run at whatever priority is appropriate
| for your server.

So just renice it:
	nice other-script &
BTW, I wouldn't normally expect nohup to be necessary in a CGI environment.

One important point to bear in mind is that the CGI output is the
stdout of the CGI script. So for the web page the user is viewing to
finish loading your bg script must redirect its standard output:
	nice otherscript >somewhere &
Perhaps the error output too, to avoid cluttering the server log:
	nice otherscript >somewhere 2>>err_log_for_the_other_script &
(The >> is to append to the file. Maybe what you want, maybe not.)

===

Subject: Re: Shell script help
From: John Summerfield <summer@OS2.ami.com.au>
Date: Thu, 1 Apr 1999 01:21:05 +0800 (WST)


On Wed, 31 Mar 1999, Paul F. Almquist wrote:

> > 
> > 
> > Am trying to write a bash cgi script which "echo"s a bunch of html stuff to
> > stdout, calls another script

You will find a construct like this better than a bunch of echos:
cat <<ZZ
<HTML>
<HEAD>
<TITLE> Equityworld Closing Prices</TITLE>

</HEAD>

<table align=left cellspacing=0 cellpadding=0 border=0>
<TR valign=top>
<TD width=500>
<center><table border=0 >
<TR>
<TD width=140><font size=2><B>Company Name</B></font></TD>
<TD width=30><font size=2><B>Code</B></font></TD> 
<TD width=40 align=right><font size=2><B>Open</B></font></TD>
<TD width=40 align=right><font size=2><B>High</B></font></TD>
<TD width=40 align=right><font size=2><B>Low</B></font></TD>
<TD width=40 align=right><font size=2><B>Close</B></font></TD>
<TD width=62 align=right><font size=2><B>Volume</B></font></TD>
<TD width=62 align=right><font size=2><B>Value</B></font></TD>

ZZ

then maybe some echos and
cat <<ZZ
</TR>
</table>
</BODY>
</HTML>
ZZ


Not you can have bash & environment variables, and back-quoted commands in
the instream data.:

cat <<
`ls -l ~$LOGNAME`
ZZ

will work as expected.


> > and quits. I want the second script to run asynchronously -but- to continue
> > running when the cgi script
> > quits. I thought of using "at" but is there a pure bash solution?
> > 
> > TIA
> > 
> start your second script with:
> 	command-to-start-script &
> or
> 	nohup  command-to-start-script &


The at command is probably better though. I assume you want the second
script to run asynchronously because it's longer running or more demanding.
You probably don't want it being run at whatever priority is appropriate
for your server.

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu