exec() gives output??

  • Thread starter Experienced but Undocumented
  • Start date
E

Experienced but Undocumented

Hi
I'd like to execute a command on the server from a PERL script. This
particular command takes a long time to execute, so I would not like the
PERL script to wait for a response. I was under the impression that exec()
would do the trick, but it doesn't...it seems to work the same as system().
Any suggestions?
Thanks!
 
J

Jürgen Exner

Experienced said:
I'd like to execute a command on the server

What server? WAIS? NTFS? HTTP? FTP?
from a PERL script. This
particular command takes a long time to execute, so I would not like
the PERL script to wait for a response. I was under the impression
that exec() would do the trick, but it doesn't...

Well, it can't.
A successful call to exec() replaces the Perl script with whatever exec() is
calling. So there is nothing left that could possibly wait for a response
from exec().
it seems to work the
same as system().

That's not correct. As the manual clearly states:
system LIST
system PROGRAM LIST
Does exactly the same thing as "exec LIST", except that a fork
is done first, and the parent process waits for the child
process to complete. [...]

Did you even bother to read even the first sentence of the documentation for
the functions you are using?
Any suggestions?

Either start the external program from system() in the background (how to do
that depends on your OS and may not be possible on all OSes) or use fork().
Details please see the man page for fork.

jue
 
E

Experienced but Undocumented

Jürgen Exner said:
Did you even bother to read even the first sentence of the documentation for
the functions you are using?

Yeah, and it's not doing what it says it should ;-)
 
J

Jürgen Exner

Experienced said:
Yeah, and it's not doing what it says it should ;-)

???
What does the doc state and what do you observe?
I would be curious to here details.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top