develooper Front page | perl.perl5.porters | Postings from January 2008

[perl #50266] Writeing to file error when using cgi that does not use http headers. FreeBSD Apache.

Thread Next
From: -
January 26, 2008 18:22
[perl #50266] Writeing to file error when using cgi that does not use http headers. FreeBSD Apache.
Message ID:
# New Ticket Created by  " -" 
# Please include the string:  [perl #50266]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is my code, it is a CGI script.

#print "Content-type: text/plain", "\n\n"; 

$file = "/usr/home/testuser/email.log";
$url = ""; # destination of the redirection 

open(TMP, "> $file") || die "2";
print TMP "xxxxxxxx";

print "location: $url\n\n";


"email.log" is owned by the account with 777 permissions.
I am invoking the script through cgi on apache.
When I run the script as it is, "email.log" has its timestamp updated, however the file is empty. The browser gets redirected to google as expected.

I tried to do some debugging and I uncommented line 2. I did not do anything else. I only removed the "#" on line 2.  When I run it this way everything works correctly. The file gets written and contains "xxxxxxxx" and the browser opens a file with the string in it.

I then commented line 2 and reran it. The file was updated, but the contents were empty. The browser was once again redirected as expected. I have tried this with and with binmode(). The results are the same.

There are no errors produced in the log files.

If I run this script from the command prompt it works as expected.

I have tried a number of things with permissions and file owner. I also tried deleting the file and letting the webserver user create the file. It will create the file just fine, but the issue with the file being empty still remains.

This is such a common use of perl that I find it hard to believe it is a new bug, but I really don't know who else to contact about this. Please let me know if you want to see this occur for yourself. I can let you log on to the test account at my server.

I am running 5.8.8. I looked all over your website for the patches for this version, but I can't seem to locate the download for them. 

Please let me know if this something you want to look into.

Kind Regards,
James Nemanich.

sp2791e# perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
    osname=freebsd, osvers=6.2-release, archname=i386-freebsd-64int
    uname='freebsd 6.2-release freebsd 6.2-release #0: sat oct 14 21:57:31 pdt 2006 i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe  -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-O2 -fno-strict-aliasing -pipe ',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Characteristics of this binary (from libperl):
  Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT
                        USE_LARGE_FILES USE_PERLIO
  Locally applied patches:
  Built under freebsd
  Compiled at Oct 15 2006 05:04:59

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About