0

I need to ZIP and then send some files using FTP. The problem is that PERL executes everything and won't wait for the compression to try to send the ZIP and the script fails.

The script in pseudocode is something like this:

system("/path/to/zip/gzip myfile.txt")
system("/path/to/ftp/ftp put myfile.txt")
8
  • 1
    Do not use System command. use perl modules Commented Aug 4, 2016 at 8:36
  • @Jens Any reason I should use perl modules over system command? Commented Aug 4, 2016 at 8:37
  • 1
    If you use perl modules you program is portable Commented Aug 4, 2016 at 8:38
  • 1
    But system should wait for the command to finish anyway. Did you perhaps add an ampersand & within the system call? Commented Aug 4, 2016 at 8:48
  • @dgw looks like that's the problem. Let me test. Commented Aug 4, 2016 at 8:52

1 Answer 1

2

system waits for the command to finish. The only way to change this behaviour is the addition of an ampersand &.

So

system( '<command> &');

will execute the command and not wait on the command to finish. To wait for the command to finish simply remove the ampersand.

system( '<command>' );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.