[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] cgi file overwrite/rename problem



I'm having problems creating a temporary file with which to update a staff
telephone list in a cgi running on a Linux box. The script runs fine (via
cgi.pm offline mode) from the command line.

Is this a permissions problem?

Noted problems when running via web:
1.  I need to create temp with 'touch' each time via telnet.
2.  Once temp actually exists, the rename fails.

    my $file = 'staff_telephones.dat';
    my $temp = 'temp';

    open (IN, "$file") or dienice( "Can't open file $file $!"); 
    open (TEMP, "> $temp") or dienice( "Can't open $temp for writing! $!");

    while (<IN>) {
        ..
        do stuff
        ..
    }

    close IN;
    close TEMP;

    rename $temp, $file or dienice("Can't rename new copy of file!");
    
I know I should be using flock. And yes, I promise to move this to use
DB_File soon. Any help, in the meantime, much appreciated!

Rory

--
		  Rory Campbell-Lange   +   The Campbell-Lange Workshop
 			                  London




==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org