in reply to system() behaviour within object(class) instance

At the risk of repeating what's have already been told by many others, we need to have more in-depht knowledge about what you consider "not working". In particular, I'd be interested into this: does your program continue after the system() when you DON'T put the ampersand character or does it continue smoothly?

When you call a program with the ampersand you're asking for this process to be run in background. This also means that your system() call returns immediately, leaving the process to do its work undisturbed. Now, some web server installation limit the total time of a running instance, so when the program you call WITHOUT the ampersand goes beyond these limits it will cause the calling process to be terminated by the web server. As a consequence, the spawned program itself would be terminated, and you'd miss your data inside the database.

Now, if this actually happens, your CGI script would die at the point you call system(), but unluckly we don't know what your "not working" means...

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: system() behaviour within object(class) instance
by Robot (Novice) on Apr 24, 2005 at 20:13 UTC
    Sorry, but i've tried to give as much details as possible. I will try to reproduce it in a simple scenario.

    Yes, the program runs smoothly.

    I know what is doing exactly background mode. Result is returned in a second when run from cli.

    Script does not die but continue its work as everything was successful (you can see my pseudocode above, there is "and warn" part if system was not successfully executed)

    10x for your attention and help. I will really try to reproduce it with some 2 or 3 simple files that to max. extent are similar to my case.
      Good to hear this, I'll be glad to take a look. The fact that the result is returned in a second when run from the CLI is weird, and seems to exclude the scenario I was depicting. Anyway, if you're sure you're running on pretty the same input data, I wonder if the webserver puts a maximum threshold to memory consumption together with total execution time.
      you can see my pseudocode above, there is "and warn" part if system was not successfully executed
      I hoped this was only some kind of example! First of all, maybe you'd use "or warn" instead of "and warn", otherwise you're getting warns only if the system() runs ok; moreover, I hope you don't deduce that your program is running smoothly only from the fact that the warn is not printed out, because if the webserver is killing your process you're not likely to arrive that far. Do you see any actual output past the system() line?

      Anyway, I'll wait to see some more code.

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.