Re: exec() gives output??

From: Jürgen Exner (jurgenex_at_hotmail.com)
Date: 10/25/03


Date: Sat, 25 Oct 2003 17:49:30 GMT

Experienced but Undocumented wrote:
> 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



Relevant Pages

  • Re: IIS 6.0 on Windows Server 2003
    ... If PHP insists on using CMD.EXE to execute the shellcommand on the ... server, then no, you have no choice -- you must give read permissions to the ... this would be a security vulnerability caused by PHP. ...
    (microsoft.public.inetserver.misc)
  • Re: Sleep freezing
    ... >> man exec. ... > form of a standard shell pipeline where each arg becomes one ... > word of a command, and each distinct command becomes a sub- ... The word "execute" means to replace the program running in the calling ...
    (comp.unix.shell)
  • Re: Error running sql command
    ... If the commands are in a table on the server, I would create strings on the server and use SQL EXECUTE to execute them... ... I fetch a command from a table, process it and if command executes successfully I delete it form the queue. ... The basic problem with your code is that you are not using SQL Server as it should be used. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: du command failing
    ... directory if the directory does not have a Read or Execute permission. ... From UNIX command line i have executed 'du' command. ... From [exec] manpage: ...
    (comp.lang.tcl)
  • Re: grant permission question
    ... returned until the command shell command completes. ... When you grant execute permissions to users, ... only members of the sysadmin fixed server ... SQL Server Agent proxy account, ...
    (microsoft.public.sqlserver.programming)