Forum Moderators: coopster & phranque

Message Too Old, No Replies

Bizarre problems with Perl/CGI

Getting no help from server administrators

         

trashmanal

10:07 pm on Dec 25, 2003 (gmt 0)

10+ Year Member



This is one of two bizarre problems I'm having with a couple of CGI scripts I'm using. I'll give the rundown on what my script is to do.

I have an account, account1.com which is hosted by host1.com ... this is the account I have the problem on.

I recently graduated from Navy OIS, and told all my fellow students they could send me their digital photos and I would post them on a website for everyone to go to. To facilitate making this page, I wrote a Perl script to find all the .jpg files in a certain folder and its subfolders. It then proceeded to make an HTML table with all of the .jpg files displayed in it.

In order to find the files in question, I used the `backticks` method to call the ls function from the shell and store the resuls in a variable called @list .

My script ran the first few times while I was debugging it. Then all of a sudden it stopped working. It would freeze up and not send any more data from the server. I noticed the HTML would stop at a point that was just before the first shell call in the program. It didn't matter if I used `backticks` or the system command, it would stop outputing before that line. (In a way, they were kind of behaving like the exec command). Not only did this happen in this script, but after this happened, all my OTHER scripts that called a shell function, which had previously worked and were untouched since, now froze up just before their shell function calls, too.

I wrote to my hosting companies tech support. They told me it was a script problem (i.e. it's my fault, not theirs).

After leaving it alone for a couple days, I tried it again and it seemed to be functioning again. I tested my script a few more times, then BOOM. It started freezing up again. I was SURE this was not just because of a bug in my script. For one, a bug in ONE script, shouldn't cause OTHER scripts to stop functioning properly. It's been like this for a week now, and has not functioned properly since.

Because I was sure it was not my fault, I decided to run a test. I am the webmaster of another site, account2 , on another hosting company, host2.

I copied some of the .jpg files and the scripts over to the account2 site and ran the scripts. As I expected, my scripts ran FINE there. However, ethically I cannot use this webspace and bandwidth for my personal needs, also aesthetically I don't want to host this page on account2 either.

To illustrate my point, here are the locations of two IDENTICAL scripts:

[account1[...]

[[small]account2[...]

NOTE: The first location WORKS INTERMITTENTLY, which means there is a small chance they could both work when you try them. Right now, however, it's consistently not working and I don't expect it to work in the near future.

The question IS, what kind of problem/misconfiguration on the server could cause this? Is there a runaway process possibly sucking up my account? Do the servers not have enough memory? Is there something not configured right? I'd like to be able to tell the prople that run the server what they can do so I can get this problem fixed, since they apparently have no idea what to do.

Again, these scripts only freeze when doing shell calls, i.e. `backticks` or system and once one script freezes, all the other scripts freeze even if previously working properly. In general, the scripts that don't make shell calls work (though I'm having other problems with them, as illustrated in my next post).

Thanks for any help you can offer.

[edited by: DaveAtIFG at 6:59 pm (utc) on Dec. 27, 2003]
[edit reason] No specifics please [/edit]

Brett_Tabke

12:56 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Many hosts will have "reaper" routines that nuke run away scripts or scripts that use to many resources. I run into one that runs on these very boxes from time-to-time. Most often, those routines will be part of a default config that the host doesn't even know about.

To test it, put a simple backtick command (check the time or do a directory list) in a script and run it over and over. If it doesn't hang, the there sounds like something wrong with the script.

tschild

7:06 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



One possible workaround would be to use Perl's built-in readdir function rather than a backticked ls - perhaps the script runs into a limitation on the number of processes?

Also worthy of a check IMO: Does the shell command inside the backticks make an implicit assumption on what 'the current directory' is? If this is so I'd try explicitly specifying the absolute path of the directory to be listed.

kenta

8:07 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



If you know it's freezing because of the back tick calls... maybe something like this would work to read them:


chdir("$mypictures/"); #set this for your pics dir
if(opendir (FILES, $mypictures)) {
while ($file = readdir (FILES)) {
push (@pictures, "$file") if ($file =~ /\.jpg/);
}
}

You can then use the @pictures array to pull out your filenames and add the additional code to format'em.