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

Sorry, but without actually seeing your code, it's hard to give a useful answer to your question. How is the object/class created, what does the system call look like?

C.

  • Comment on Re: system() behaviour within object(class) instance

Replies are listed 'Best First'.
Re^2: system() behaviour within object(class) instance
by Robot (Novice) on Apr 24, 2005 at 10:15 UTC
    CGI script is like

    ... object instantiation ...
    $obj->run()


    Perl Module is like

    ... object definition (a very long and complex one) ...
    sub run {
    ... normal sub definition (a lengthy one also) ...
    system "command param &" and warn '';
    }


    so if the call is like:
    system "command param" it does not work and no error is actually raised in any mode
    system "command param &" does strangely work

    the problem is that param is some internally computed runtime id and what I tested also is to assign that id to some global variable to CGI script through $main::global_var and when executing the same system "command param" it does work but it's not a suitable variant to use (so i did use & variant)
      calling system inside or outside a method call can not affect is behaviour in any way.

      Have you checked that you are calling the external program with the right arguments? try replacing the command by "echo" and see what is printed.

      If everything else fails, try some process monitoring tool like (depending of your OS) truss, strace, ktrace, etc. (btw, make it monitor forked child processes).

      Maybe the program you are calling is waiting for some input from stdin, maybe $param is undef...

        "calling system inside or outside a method call can not affect is behaviour in any way"
        Yes, that's why I am posting it here

        "Have you checked that you are calling the external program with the right arguments? try replacing the command by "echo" and see what is printed. "
        Of course, I did these multiple times. As I said it does work with & at the end.

        "Maybe the program you are calling is waiting for some input from stdin, maybe $param is undef... "
        Nope, it's all correct (no stdin input) otherwise it won't work with & also!


        10x for your attention :)