Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Anyone know why I can't make a system call using a perl script from an entry in a form. I'm using -T I have a couple of x10 components I want to turn on via a form entering a certain string to activate them
if ($value =~ /SOMEVALUE/) { print "<H3>Value is correct</H3>"; $command = "C:\\progra~1\\homeco~1\\x10comm.exe a2 on"; exec($command); }

Replies are listed 'Best First'.
Re: CGI and System
by tadman (Prior) on Jul 13, 2002 at 00:06 UTC
    You should probably be using system instead of exec. Remember that exec actually converts the currently running process into the given command, which might not work as well in a http-process environment.
    open(X10, "$command|"); print join('', <X10>); close(X10); # Or print `$command`
    Unless you are getting an error, in which case you may want to use CGI::Carp.
Re: CGI and System
by dws (Chancellor) on Jul 13, 2002 at 02:59 UTC
    I have a couple of x10 components I want to turn on via a form entering a certain string to activate them

    tadman answered your question. I'll add \the obligatory mention of MisterHouse, an X10 home management system written in Perl. Therein you'll learn the secrets of speaking the X10 protocol directly, rather than having to invoke a separate program. This has performance advantages if you're polling for events.