Operating System - HP-UX
1753288 Members
5595 Online
108792 Solutions
New Discussion юеВ

perl problem -- endless loop only with web

 
SOLVED
Go to solution
Anna Fong
Advisor

perl problem -- endless loop only with web

Hi,

My perl app makes a file based on a date that is passed in. If two dates are passed in, it'll make several files one for each date in the range by running thru the code for the first date and then calling itself in a loop with each subsequent date.



if ($doMultiple) {
foreach $dates (@dates) {
system "/path2apps/myAppName $dates";
}
}

When I run my app on the command line, it makes all the files and exits.

When I run the app from the web, it goes into an endless loop. I added some debug statements to check the dates in my dates array and they are what is expected -- one date for each day in the range.

Can anyone offer help?


TIA,
Anna
4 REPLIES 4
Rodney Hills
Honored Contributor

Re: perl problem -- endless loop only with web

The main factors that might prevent an application from running in a non-interactive environment are-

1) What is the current directory
2) Who is the user the app is running as
3) What the value of PATH is
4) If STDIN/STDOUT/STDERR are set to a terminal

An interactive session will have these critical items setup (via .profile).

Do you know where in the script it is looping?

-- Rod Hills
There be dragons...
Steven E. Protter
Exalted Contributor

Re: perl problem -- endless loop only with web

Sounds like an environment issue.

I'm attaching perl script that displays environment at perl run time.

It might help you out.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Anna Fong
Advisor

Re: perl problem -- endless loop only with web

I solved my problem by changing the logic of the app. Rather than running thru the code for the first date and then calling itself with each subsequent date in a loop, I changed it to loop thru the code for each date in the range.

I still don't know why it worked in its previous form on the command line and not via the web, other than perhaps it has something to do with how CGI works.

Anna
Elmar P. Kolkman
Honored Contributor
Solution

Re: perl problem -- endless loop only with web

Are you using mod-perl, by any chance?
In that case, execution of external programs is not always supported.

Best way, anyway, is to keep as much as possible in one executable. In your case, a simple solution would have been to not call your script using system, but to put the stuff you need to do in a function and call that function on the line you now have the system call...
Every problem has at least one solution. Only some solutions are harder to find.