Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

running perl-cgi scripts using different sessions

     

gsarin

2:17 am on May 27, 2009 (gmt 0)

5+ Year Member



Hi,

I have a perl-cgi script that is running fine when one user runs it.

How do i make it run for many users? My basic knowledge tells me that I have to use sessions. But How?

I am mot into web programming. Any basic pointers or sample scripts will be appreciated?

phranque

5:45 am on May 27, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



this is probably a good starting place to learn about perl sessions:
CGI::Session - persistent session data in CGI applications - search.cpan.org [search.cpan.org]

you really only need sessions if you need to maintain persistent data for each visitor.
typically sessions are maintained by using cookies or a session id parameter, which is what the CGI::Session module will do for you.

gsarin

6:00 am on May 27, 2009 (gmt 0)

5+ Year Member



Below are the some of the details of my script. I am not sure if i need session?

perl-cgi script (hosted on apache server) is running fine when one user runs it through web page. The script is called when user selects some arguments and presses submit button from HTML form using get method. The script inturn calls some batch files using system command and does some other things depending on the arguments selected by user.

Currently if more than one user tries to run the script, the user starting later gets errored out because the system command that runs batch file throws an exit status of 1. But the script before & after system command does run properly. Do I still need sessions? Am I looking into the right direction?
Or is this some other issue?

Thanks,
Gaurav

phranque

10:04 am on May 27, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



what are the values of the perl special variable $? [perldoc.perl.org] and the perl special variable $! [perldoc.perl.org] after the system call?

gsarin

11:03 am on May 30, 2009 (gmt 0)

5+ Year Member



Hi,

Thanks for replying.

I was able to figure out the error which was nothing to do with sessions. My system command was something like this:

$res=system("Gtest\\_Bud_.bat >E:\\Temp\\garbage.err");
$res=system("Gtest\\_dump_.bat >E:\\Temp\\garbage.err");

when multiple users were tryng to run different batch files, the issue was with garbage.err file which was getting locked. I have solved the issue by using different names for these garbage.err files for different batch files.

I am planning refine this fix and use session id's for these file names.

But I am stuck with another issue now. If, from a single computer I try to run more than two different batch files by submitting the form more than two times, nothing happens at the third submit (No batch file runs). The browser just hangs, the IE progress bar does not display anything, untill any any one of the batch file's initiated earlier completes. If one of the batch files intitiated earlier takes a lot of time to complete the third submit just times out.

In summary, the perl-cgi script can have only 2 parallel runs, and I think this also means that the script will not support more than 2 users at a time.

Is there some kind of configuration setting in Apache server to let multiple instances of .pl script to run simultaneously?

The form submit code is as below:
<FORM METHOD="GET" action="http://server name/test_cgi.pl" TARGET="_blank">

I am also using the following piece of code at the beginning of the script to prevent the output of the batch run from being displayed on browser:

$¦=0;
close(STDERR);
open(STDERR, "> E:\\Temp\\calcconsole\\output.err");

Any pointers will be appreciated.

Thanks,
Gaurav

chorny

10:35 am on Jun 25, 2009 (gmt 0)

5+ Year Member



You should test if you can run 3 programs without web server.

Apache has no CGI-specific limits for number of parallel processes.

phranque

9:04 am on Jun 26, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



maybe there is a limit on concurrent connections to the database or some other resource is maxing out.
have you looked to see of a third process is started for the third script?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month