Deleting a file while other script still appending to



Hi all,

I have a script that logs activities to a txt log file. I noticed that when deleting the file from another window or shell, the script stops writing to the file. I was expecting something like the unix shell, which is creating a new file and appending to it.

execute this script:
#!/usr/local/bin/perl
use FileHandle;
open(LOGFILE,">>logFile");
LOGFILE->autoflush;
while (1) {
sleep 1;
print LOGFILE ("test\n");
}

After few seconds, and from another terminal, delete the file that was created by the script, notice that the script won't stop or error out, but in the same time no new file is created.

Thanks,
Mahdi

.



Relevant Pages

  • Re: detect shell script language
    ... In the 'old' days, when a user typed in a command, the interactive shell would immediately pass it off to 'exec' to execute. ... So, on return from exec with an error status, the shell would fork a copy of itself to try and run the script. ... As a result of the above, it was hard to tell whether the script was a Bourne shell or C shell, so the convention was introduced of using the Bourne shell no op command, as the first line in a Bourne shell script. ...
    (Debian-User)
  • Re: Call for input on comp.unix.shell FAQ
    ... >> questions and just tell people to FAQ it. ... The other level is how to write shell scripts. ... How can I remove whitespace characters within file names? ... Why one shouldn't use "echo" in a script? ...
    (comp.unix.shell)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.shell)
  • Re: Affecting Institutional Change (Yeah Right)
    ... provides labs in most non-dorm buildings replete with the wonderful ... be run from a shell, no idea what an executable was, and, in fact, ... IDE program, go through a ton of menus to pick the right script, go ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.admin)