Re: File Writing and CGI
On Nov 20, 2003, at 11:41 PM, Gohaku wrote: When I tried use CGI::Carp qw(fatalsToBrowser) I saw the following: Internal Server Error I also ran the script from a browser as Root and I still got the same message. Make sure that the script is executable by the user that apache runs as. Something like: chmod 744 my_script sudo chown apache my_script I'm actually not running apache on my machine, so I don't know if the apache user is 'apache'. If not adjust the command above accordingly.
Re: making Perl scripts run
On Wednesday, August 27, 2003, at 04:56 PM, Charlie Root wrote: mrsparkle ellem ~/code $ phonetic.pl bash: phonetic.pl: command not found mrsparkle ellem ~/code $ sudo chmod +x phonetic.pl Password: mrsparkle ellem ~/code $ phonetic.pl bash: phonetic.pl: command not found mrsparkle ellem ~/code $ perl phonetic.pl Enter some letters and numbers: ASF19 alpha sierra foxtrot one niner What am I doing wrong? I'd like perl scripts to work without my typing perl first. phonetic.pl is not in your path. If you try: ./phonetic.pl it should run. If you are running the default shell, tcsh, you can add the following line to ~/.cshrc: setenv PATH ${PATH}:. That way the current directory (.) is always in your path. smalltime industries www.smalltime.com Now in 2D!
Re: Restart Apache
On Tuesday, November 26, 2002, at 11:55 AM, Jeremy Schwartz wrote: I am trying to rotate my Apache logs using Cron and the following shell script: # /bin/sh mv /var/log/httpd/access_log /users/admin/logs/ apachectl restart This script is set to 755 and is being executed by the root crontab. The first line is executing correctly, the log file is moving out of /var/log/httpd/ to /users/admin/logs/ but apache is not restarting. My first guess is that apachectl is not in the path for the script. Try putting in the full path for apachectl. If that still doesn't work, have you checked the error log for apache to see if it's dying on startup??
Re: unix or mac-style text files?
An alternative is to read the entire file in (undef $/) and then split it: My suggestion is to put some code like this in your script: local $/ = get_line_ending($fh); sub get_line_ending { my $fh = shift; my $char; while (read $fh, $char, 1) { if ($char eq \n) { seek $fh, 0, 0; return \n; } elsif ($char eq \r) { if (read $fh, $char, 1 and $char eq \n) { seek $fh, 0, 0; return \r\n; } else { seek $fh, 0, 0; return \r; } } } ## what, no line ending? ## return a reasonable default seek $fh, 0, 0; return \n; } This, of course assumes that you don't have some oddball case where you have \r's in a unix file or something like that, but if you're dealing with text files (which is the only place where line endings should matter), that's unlikely. Suggestions for the above code: Move the sub into a module. Put a byte counter in, so that you're not reading through a 5 Gig file looking for a line ending. I assume it's more efficient to read small chunks of bytes rather than byte by byte. For most text files this shouldn't matter, but you may want to alter the reads and also the comparisons if you care.
Re: Adding path to @INC for use with web server
From: Adam Witney [EMAIL PROTECTED] Date: Thu, 10 Oct 2002 11:09:38 +0100 To: MacOS X perl [EMAIL PROTECTED] Subject: Adding path to @INC for use with web server Hi, Searching the archives I have been able to find out how to get Perl to search other paths for modules when invoked from the terminal or from GUI apps such as BBEdit, however I cannot get them recognised by cgi scripts. I read somewhere to add this line to httpd.conf You can include this code in httpd.conf: Perl use lib ''; /Perl I assume that this directive requires mod_perl Alternatively you can do PerlRequire /../../perl_config_file.pl and then in that perl config file, include your 'use lib' code.
Slow file upload in 10.2
I sent out this email a while ago and got no replies, so I'm trying one more time: After updating to Mac OS 10.2, I've noticed that my perl file uploads (using HTTP::Request::Common) have slowed down by a lot. Using tcpdump, I see that there is a long delay before the first packet is sent. Playing around with file sizes, I found a very strong file-size dependence: File Size Time till first packet 15M 4 sec 17M 76 sec 19M 180 sec 24M 555 sec This is the test code: #!/usr/bin/perl use HTTP::Request::Common; use LWP::UserAgent; my $ua = LWP::UserAgent-new(); $ua-timeout(60*10); $response = $ua-request(POST 'http://my_url_', Content_type = 'form-data', Content = [ upload_file = ['my_big_file...'] ]. ); print $response-content; That 24M file, which used to take a minute or two, now takes over nine minutes before the upload even starts. I just tried updating my perl installation to 5.8.0, but that didn't help. At this point, I don't know if this is a perl problem or not. -- g
Slow file upload in 10.2
After updating to Mac OS 10.2, I've noticed that my perl file uploads (using HTTP::Request::Common) have slowed down by a lot. Using tcpdump, I see that there is a long delay before the first packet is sent. Playing around with file sizes, I found a very strong file-size dependence: File Size Time till first packet 15M 4 sec 17M 76 sec 19M 180 sec 24M 555 sec This is the test code: #!/usr/bin/perl use HTTP::Request::Common; use LWP::UserAgent; my $ua = LWP::UserAgent-new(); $ua-timeout(60*10); $response = $ua-request(POST 'http://my_url_', Content_type = 'form-data', Content = [ upload_file = ['my_big_file...'] ]. ); print $response-content; That 24M file, which used to take a minute or two, now takes over nine minutes before the upload even starts. I just tried updating my perl installation to 5.8.0, but that didn't help. At this point, I don't know if this is a perl problem or not. -- gc