in reply to sysopen function call

Maybe $fullLogFile contains whitespace? I always use delimiters around filenames like this:

sysopen(LOGFILE, $fullLogFile, O_RDWR | O_CREAT) or die "Cannot open '$fullLogFile' for writing: $!";

Also, is there any reason you're using sysopen instead of plain open? Also, you should better use lexical filehandles instead of global filehandles:

open(my $logfile, '+>', $fullLogFile) or die "Cannot open '$fullLogFile' for writing: $!";

Replies are listed 'Best First'.
Re^2: sysopen function call
by rpike (Scribe) on Sep 08, 2010 at 14:12 UTC
    No white space. I checked to make sure of that from command line as opposed to running it as a CGI app (what it's intended to do). If you have a way of accomplishing what I need to do using the open function I'm all ears but I've already posted what I wanted to do prior to this and open doesn't seem to cut the cake. I need to open a file and have a lock on it, read in contents, modify those contents, have those contents written back to the file (overwrite everything in the file with the new stuff), and then release the lock. open didn't work for me.

      If it is running as a CGI app, but not doing what it should, then it is a permission problem between the user your web server runs your application as and the user you use to test from the command line. Maybe your system is using SELinux or something else that interferes, or your webserver is running in a chroot jail.

      open should work for you in your use case, but you don't show any code so it's hard to tell where it fails to do so for you.

        That's about it.
        use List::Util; sysopen (my $logHdl, "C:/directory1/directory2/directory3/logs/LOGFILE +.txt", O_RDWR | O_CREAT) or die "Content-type: text/html\n\nCannot op +en file for writing. ".$!;
        The only code I'm trying out is a sysopen line as you can see. The web user has full permissions needed, first thing I checked. The code actually fails from command line as well so both users are in the same boat.