Re: Killing a Process

2004-11-22 Thread Tim Bunce
There ought to be a better way. I'm not very familar with web issues
but for plain CGI I'd have expected a SIGHUP and/or SIGPIPE to be
delivered to the process. Those could be caught and trigger cleanup.

Tim.

On Sun, Nov 21, 2004 at 09:12:30AM -0700, Reidy, Ron wrote:
 Look at setting the sqlnet.expire_time parameter in your server's 
 $ORACLE_HOME/network/admin/sqlnet.ora file.

 From: Kevin Bass [mailto:[EMAIL PROTECTED]
 
 I have a slight problem that I am attemping to solve. I am using CGI/Perl
 (DBD Oracle) on Linux AS 2.1 to access to the database. When users encounter
 problems on the web, they cancel (or press stop) in their browsers. This
 will stop there browser interaction and also cause the database connection
 to not disconnect which causes a runaway process. Is there an article that I
 can read or a procedure/module or process that someone has written within
 CGI or DBI (or sometimes else) that will allow me to kill my database
 connection when a users stops an execute within his/her browser?  Thanks!
 
 Kevin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Killing a Process

2004-11-22 Thread Bob Showalter
Kevin Bass wrote:
 I have a slight problem that I am attemping to solve. I am using
 CGI/Perl (DBD Oracle) on Linux AS 2.1 to access to the database. When
 users encounter problems on the web, they cancel (or press stop) in
 their browsers. This will stop there browser interaction and also
 cause the database connection to not disconnect which causes a
 runaway process. Is there an article that I can read or a
 procedure/module or process that someone has written within CGI or
 DBI (or sometimes else) that will allow me to kill my database
 connection when a users stops an execute within his/her browser? 
 Thanks!  

When the user presses the Stop button on their browser, the only thing
that happens is the connection back to the server is closed. The only way
for your script to detect this is to try to send data back to the client. If
the connection is closed, you'll receive SIGPIPE (which by default will
terminate your process). 

You can catch the SIGPIPE and do a graceful shutdown on the db connection.

If you're in the middle of a query, you won't be able to detect the
connection being closed until the DBI call returns.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: question about doing it right in CGI

2004-11-22 Thread Sean Davis
I use the object-oriented interface pretty much exclusively.  There are good 
examples of creating a popup menu in the documentation for CGI.  (You know 
about http://search.cpan.org?)  Also, there are multiple websites describing 
use of CGI.pm.  I would suggest that you start with a simple cgi script 
using CGI.pm that does nothing other than create a popup menu.  Use your web 
browser's view source command to see what is generated and then try to 
modify your CGI script to make the HTML appear as you like.  Other modules 
that you might find interesting are Class::DBI and html::fillinform

Sean
- Original Message - 
From: Lewick, Taylor [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 19, 2004 2:51 PM
Subject: question about doing it right in CGI

Hi all, I have been using perl for sometime for CGI scripts, but have
always used the print content-type:html version of doing things.
I would like to learn a better way with the CGI module, but when I read
the docs I find it pretty easy to get confused as to whether I should
use the object oriented method, or the functional method.
Also, because my script is a cgi form that gets some of the select
fields from a mysql database, I am not sure how to convert that over.  I
don't know how I would make the select field work the same.
I am not asking for someone to rewrite my project, merely provide me
with some examples of how they would write the same code using the cgi
module so I can figure this out a bit better...
On my form, I am querying a database for a list of names and loading
them into a select box.  But I found out people want to enter more than
one name at a time, so I loop through 15 times, and they can select up
to 15 names...  They select a name, but I store the name's id, so it
acts as a lookup field...
Here is how I do this now..
#Connect to database
print table\n;
for (1..15) {
print td nowrap\n;
$query_teams=(select id, name from teams);
$sth = $dbh-prepare($query_teams);
$sth-execute();
$sth-bind_columns(\$id, \$name);
print select name='away_team$_'; #$_ traps which pass of the loop
we are in i.e., 3rd pass, 4th pass, etc
print option value='0'/option\n;
while($sth-fetch()) {
print option value='$id'$name/option\n;
}
print /select\n;
$sth-finish();
print /td\n;
} #end for loop
print /table\n;
#disconnect from database
How would I start to convert this with the CGI module.  My problems thus
far are on a popup menu, how do I specify the field variable that I grab
is the ID, while the displayed value is another, and how can I say the
first value should be 0, in case they do not enter anything?
Thanks in advance,
Taylor
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Running a DOS app under iIS?

2004-11-22 Thread Michael Coats
Hi,

You might need to set the execute permission on the pkunzip exe for the
iusr_local_machine or whatever user it is that IIS uses. Or maybe even try
fiddling with permissions on the files that the program works on - just
because your user can run the programs and access the files, doesn't mean
that IIS' user account can.

HTH,
Mike

-Original Message-
From: Brian Hancock [mailto:[EMAIL PROTECTED] 
Sent: 20 November 2004 11:53
To: [EMAIL PROTECTED]
Subject: Running a DOS app under iIS?

Hi

I am having trouble getting a DOS executable program to run from my PERL
script. I have been successfully running the scripts under Apache 2.0 and
ActivePERL 5.8 on my XP box, with both the local client and remote clients.
When I uploaded the script to my webhost which run IIS5 I get an Access
Denied. The webhost's support have been unable to help me.

I have am now trying it out on my IIS5.0 on Windows 2000, and although I am
not getting the same error message, my application is not running as
expected.

I thought it might be easier to use a different DOS program than my app in
case it was the problem so I have been trying the old faithful pkunzip.exe
and am getting some unexpected results.

If you start pkunzip at a command prompt without any parameters eg
c:\pkunzip then you get a help message sent to stdout..

To test an archive you start PKUnzip
c:\pkunzip -t myzip.zip
and if the zipis is ok then a message verify the integrity of the zip is
sent to stdout.

Various version of my PERL script to start PKUnZip have been

#!c:\perl\bin\perl.exe -w
#unzip.pl
print Content-type:text/html\n\n;
system(pkunzip)
print html ;
system(pkunzip.exe -t myzip.zip)
print Done ;
print /html ;

The only output is Done:

changing the System line to:
system(cmd /c pkunzip.exe);
is far better as I receive the expected Help message

I eventually got at least something along the lines I wanted with  with:
system(cmd,/c,pkunzip.exe,-t,
c:\\inetpub\\wwwroot\\cgi-bin\\myzip.zip)
However although it can fine the myzip.zip file the error message coming
from PKUnzip is that is can't open it?

I can run the script from the Command Prompt by just type zip.pl and it runs
fine.

Can anyone shed some light on this.

By the way, I think I mentioned it earlier but I have no problems when
running this under Apache.

Thanks
Brian








This message is intended only for the use of the persons (The intended 
recipients) to whom it is addressed. It may contain information which is 
privileged and confidential within the meaning of applicable law. If you are 
not the intended recipient, please contact the sender as soon as possible. The 
views expressed in this communication may not necessarily be the views held by 
James Jones  Sons Ltd.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




perl.beginners.cgi Weekly list FAQ posting

2004-11-22 Thread casey
NAME
beginners-faq - FAQ for the beginners-cgi mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?
Send mail to [EMAIL PROTECTED]

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

[EMAIL PROTECTED].

  1.2 -  How do I unsubscribe?
Now, why would you want to do that? Send mail to
[EMAIL PROTECTED], and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

[EMAIL PROTECTED]

  1.3 - There is too much traffic on this list. Is there a digest?
Yes. To subscribe to the digest version of this list send an email to:

[EMAIL PROTECTED]

To unsubscribe from the digest, send an email to:

[EMAIL PROTECTED]

  1.4 - Is there an archive on the web?
Yes, there is. It is located at:

http://archive.develooper.com/beginners-cgi%40perl.org/

  1.5 - How can I get this FAQ?
This document will be emailed to the list once a month, and will be
available online in the archives, and at http://beginners.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?
Send an email to [EMAIL PROTECTED] with your suggestion.

  1.7 - Is there a supporting website for this list?
Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who do I complain to?
Complaints can be sent to [EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?
Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?
Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl/CGI beginners.

  1.11 - When was this FAQ last updated?
Feb 04, 2004

2 -  Questions about the 'beginners-cgi' list.
  2.1 - What is the list for?
A list for beginning Perl programmers to ask questions in a friendly
atmosphere. The topic of the list is, of course, CGI with Perl.

  2.2 - What is this list _not_ for?
* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Non Perl/CGI questions or issues
* Lemurs

  2.3 - Are there any rules?
Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun

  2.4 - What topics are allowed on this list?
Basically, if it has to do with Perl/CGI , then it is allowed. If your
question has nothing at all to do with Perl/CGI, it will likely be
ignored.

  2.5 - I want to help, what should I do?
Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?
We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?
Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

perldoc perldoc

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?
* Perl.org - http://www.perl.org
* Perl Home Page - http://www.perl.com
* PerlMonks - http://www.perlmonks.org
* Perldoc - http://www.perldoc.com
* Perl Archives - http://www.perlarchives.com
* NMS Archive - http://nms-cgi.sourceforge.net/
* Unofficial Perl Beginners' Site - http://perl-begin.berlios.de

  3.2 - What resources may be harmful to a beginner?
Beware of Perl4-like code-- You might find some script archives and
unauthorized mirrors with old Perl4 versions of Selena Sol and Matt
Wright scripts. Don't use those scripts. They are outdated and may even
in some cases 

Variable interpolation inside an externa js file?

2004-11-22 Thread Siegfried Heintze
In my perl script I have put my javascript code in a separate file with the
extension of js. I reference it with a javascript tag in the HTML. I have
some code in there that is not in a procedure: it just executes prior to the
body of the page loading as inline statements.

Now I discover I need some of those URLs in my external javascript file to
change depending on some perl parameters.

This is not a procedure so I cannot just change some javascript procedure
parameters. Perl does not process this file so it won't do the variable
interpolation I want either.

Below is the code that is causing the problem.

I think the only way to resolve this is to cut the code below and move it to
the perl code where I can use interpolation (which I would prefer not to do
because it will really clutter up the main program -- oh well).

Can anyone suggest a better approach?

Thanks,
  Siegfried


if (document.images) {
  one_on= new Image ();
  one_on.src= http://www.decisionchannel.com/breturn2.gif;;
  one_off   = new Image();
  one_off.src   = http://www.decisionchannel.com/return2.gif;;
  two_on= new Image ();
  two_on.src= http://www.decisionchannel.com/f_bwhatbut2.gif;;
  two_off   = new Image();
  two_off.src   = http://www.decisionchannel.com/f_whatbut2.gif;;
... // more of the same
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Killing a Process

2004-11-22 Thread Henri Asseily
On Nov 22, 2004, at 5:30 AM, Bob Showalter wrote:
Kevin Bass wrote:
I have a slight problem that I am attemping to solve. I am using
CGI/Perl (DBD Oracle) on Linux AS 2.1 to access to the database. When
users encounter problems on the web, they cancel (or press stop) in
their browsers. This will stop there browser interaction and also
cause the database connection to not disconnect which causes a
runaway process. Is there an article that I can read or a
procedure/module or process that someone has written within CGI or
DBI (or sometimes else) that will allow me to kill my database
connection when a users stops an execute within his/her browser?
Thanks!
When the user presses the Stop button on their browser, the only 
thing
that happens is the connection back to the server is closed. The only 
way
for your script to detect this is to try to send data back to the 
client. If
the connection is closed, you'll receive SIGPIPE (which by default will
terminate your process).

You can catch the SIGPIPE and do a graceful shutdown on the db 
connection.

If you're in the middle of a query, you won't be able to detect the
connection being closed until the DBI call returns.
Note that while a plain CGI script might get a SIGPIPE, it won't be the 
case under mod_perl. There are no pipes under mod_perl and I have no 
idea how one would go about knowing if the user severed the connection.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Killing a Process

2004-11-22 Thread Henri Asseily
On Nov 22, 2004, at 5:30 AM, Bob Showalter wrote:
Kevin Bass wrote:
I have a slight problem that I am attemping to solve. I am using
CGI/Perl (DBD Oracle) on Linux AS 2.1 to access to the database. When
users encounter problems on the web, they cancel (or press stop) in
their browsers. This will stop there browser interaction and also
cause the database connection to not disconnect which causes a
runaway process. Is there an article that I can read or a
procedure/module or process that someone has written within CGI or
DBI (or sometimes else) that will allow me to kill my database
connection when a users stops an execute within his/her browser?
Thanks!
When the user presses the Stop button on their browser, the only  
thing
that happens is the connection back to the server is closed. The only  
way
for your script to detect this is to try to send data back to the  
client. If
the connection is closed, you'll receive SIGPIPE (which by default will
terminate your process).

You can catch the SIGPIPE and do a graceful shutdown on the db  
connection.

If you're in the middle of a query, you won't be able to detect the
connection being closed until the DBI call returns.
I take back my previous email. For mod_perl please check the docs:
http://perl.apache.org/docs/1.0/guide/ 
debug.html#Handling_the__User_pressed_Stop_button__case

H
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Variable interpolation inside an externa js file?

2004-11-22 Thread Shaun Fryer
On Mon, Nov 22, 2004 at 01:21:35PM -0700, Siegfried Heintze wrote:
 In my perl script I have put my javascript code in a separate file with the
 extension of js. I reference it with a javascript tag in the HTML. I have
 some code in there that is not in a procedure: it just executes prior to the
 body of the page loading as inline statements.
 
 Now I discover I need some of those URLs in my external javascript file to
 change depending on some perl parameters.
 
 This is not a procedure so I cannot just change some javascript procedure
 parameters. Perl does not process this file so it won't do the variable
 interpolation I want either.
 
 Below is the code that is causing the problem.
 
 I think the only way to resolve this is to cut the code below and move it to
 the perl code where I can use interpolation (which I would prefer not to do
 because it will really clutter up the main program -- oh well).
 
 Can anyone suggest a better approach?

I'd suggest loading the js file using HTML::Template. Substitute the code you
want with a TMPL_VAR /, and write some logic so that if the query string
contains foo.js (a slight oversimplification) that it loads that template,
prints it, then exits. Does that make sense to you? Anyone else?

-- 
=
 Shaun Fryer
=
 http://sourcery.ca/
 ph: 416-544-9461
=


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response