in reply to Re: Frustrated with system calls
in thread Frustrated with system calls

Well, in theory, it's supposed to wait. I do not use &. I have found that:
  • - it does not wait for "cp" commands to finish. When I say system("cp a b") or `cp a b`, it will go to the next command while b is still at file size 0.
  • - it does not wait for binary executables to finish. If I say system("executable > abc") or `executable > abc`, it will proceed to the next line while abc is still growing.

    Could any of this behavior somehow be caused by the CGI module?

  • Replies are listed 'Best First'.
    Re: Re: Re: Frustrated with system calls
    by jynx (Priest) on Feb 14, 2001 at 02:19 UTC

      Two basic rules that are generally true when dealing with commands is to always check the return values and to keep as much within perl as you can. Try using the File::Copy module (not certain if it comes with 5.005), it should make things easier as it will error to screen something useful (not always true of system commands).

      For a command like cp perl will wait in my experience. If you are worried about this you can pause your script for a second (or whatever time it usually takes plus some seconds for good measure) to make certain the shell command is finished. But also check the return value (with the system call this is relatively easy), just in case.

      HTH,
      jynx

    Re: Re: Re: Frustrated with system calls
    by goldclaw (Scribe) on Feb 14, 2001 at 02:08 UTC
      Both of these could be caused by the OS, at least if the files b and abc are on disks mounted through nfs. The programs are done, but the data hasn't been written to disk yet. Do you know if those files are on an nfs-mounted disk? If so, try putting them on a local disk, that might help.

      GoldClaw