Problem with system

Problem with system

am 24.10.2008 19:32:02 von Sergey Kochkarev

Hi,

I'm new to mod_perl and I got the following problem:

1. system() outputs to browser. How can I turn this off?
2. `` works in parallel with perl script, but I want it to finish to
check the files it creates. How can I synchronize `` and perl?

I've googled the sfio term that seems to be the key to the problems. Is
there any way to turn sfio off?

Thanks,
Sergey.

Re: Problem with system

am 24.10.2008 21:01:34 von aw

Sergey Kochkarev wrote:
> Hi,
>
> I'm new to mod_perl and I got the following problem:
apparently not just to mod_perl..

>
> 1. system() outputs to browser. How can I turn this off?
Well, yes.
Anything basically that your script or module prints to STDOUT, will end
up "in the browser". That's the normal way things work with cgi-bin
scripts (whether mod_perl is involved or not).
Since whatever you run "in" system() runs as a sub-process of your
script, it prints to the same STDOUT as your script, in other words to
the browser too.
If you do not want this, then re-direct the output of the command that
you run in system().
E.g.
system('ls -l > /dev/null');

> 2. `` works in parallel with perl script,
as far I know, it doesn't. `command` means that you want to run
"command", and want to grab whatever it prints to STDOUT, tu put it
somewhere. In other words, `command` is a perl statement that returns a
value, and this value is the output of "command".
What is the full line where this appears ?
You normally would have something like
my $var = `command`;
and if you do, then your script, under mod_perl or not, will nicely wait
until "command" finishes, and put everything that "command" prints to
STDOUT, into $var.
Then the script will continue, but not before "command" is finished.

but I want it to finish to
> check the files it creates.
What does "command" exactly do ?

How can I synchronize `` and perl?
>
> I've googled the sfio term that seems to be the key to the problems. Is
> there any way to turn sfio off?
I have no idea what that is, but I doubt that it is really the cause of
your problems.