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

Hello, I don't mean to sound frustrated, but as always I'm having a tough time making things work correctly with windows, Ok enough complaining, this is my problem. I have several X10 components, and I just wish (at this point to simply turn them on and off) I have added the path to the executable (x10com32.exe) to my system path environment varible so I can call the command from anywhere. Here is my code
#!perl.exe -wT use Strict; use CGI; my $q = new CGI; print $q->header("text/html"); print"<h2>Turning Lights ON</H2>"; my $command = join ("", "x10comm.exe ", "a2 ", "on"); system($command);
The command works fine from the cmd window, but will NOT work when I call it from my browser.....AARRRRGGGHHH!!!! Any suggestions, or I have I been staring blindly at this VERY SIMPLE code, and have overlooked something. I'm using the latest version of apache for Windows XP, and the cgi perl module. Thanks

Replies are listed 'Best First'.
Re: X10 and Windows
by tstock (Curate) on Aug 06, 2002 at 01:40 UTC
    is x10comm.exe in the search path for the webserver ? Try fully qualifying the path to the executable.

Re: X10 and Windows
by fokat (Deacon) on Aug 06, 2002 at 02:43 UTC
    Hmmm, where you say

    my $command = join ("", "x10comm.exe ", "a2 ", "on");
    There is actually a space in the first argument to the join(), isn't it? Otherwise, you would be attempting to call "x10comm.exea2on".

    Also, in your post you talk about x10comm32.exe yet in your code, you attempt to call x10comm.exe. Which one is the right one?

    Edit:Typo and name of the executable


      Either one will work, but to add more fuel to the fire, I can run the following code successfully:
      #!perl.exe -w use Strict; use CGI; my $q = new CGI; print $q->header("text/html"); print"<h2>Turning Lights OFDF</H2>"; system "copy on.cgi on2.cgi"
      Notice I turned the flag for Taint (-T) Checking off. This isn't the same command but executes without -T. I still can't seem to execute my system call for my X10 Module, but I think I'm starting to see the light.
Re: X10 and Windows
by mumbles (Friar) on Aug 06, 2002 at 12:14 UTC
    Anything to do with Perl and X10 can probably be found there.
Re: X10 and Windows
by Rex(Wrecks) (Curate) on Aug 06, 2002 at 01:47 UTC
    You might want to get and print the results of the system() command. This is relativly easy and could shed a whole lot of light on what is or is not happening.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
      It seems to be printing the command correctly before the system call, but nothing ever appears after I call 'system($command)' I'm lost!
        You could try calling system() like this:
        system($command) == 0 or warn "System call failed with error # $?";
        Or try using backticks:
        print `$command`;
        Between the two you hopefully should get something useful for diagnostics.
        Try this:
        my @test = system($command) ; print @test ;

        This will give you the command output. Example:
        #!/usr/bin/perl -w use strict ; my @test = system("dir") ; print @test ;

        Will give you:
        Volume in drive E is E_Drive Volume Serial Number is XXXX-XXXX Directory of E:\TempCode\test 08/06/2002 11:05a <DIR> . 08/06/2002 11:05a <DIR> .. 08/06/2002 11:05a 1,336 1 File(s) 1,336 bytes 2 Dir(s) 1,629,966,336 bytes free 0
        #!/usr/bin/perl -w use strict ; my @test = system("dirt") ; print @test ;

        Will give you:
        'dirt' is not recognized as an internal or external command, operable program or batch file. 256
        This should be usefull in at least telling you if the command is being executed and what the results are.

        "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!