Perl system command not executing

Discussion in 'Perl Misc' started by CoralBanded, Jan 7, 2004.

  1. CoralBanded

    CoralBanded Guest

    I am trying to run a command from a web page using perl. The server
    is Win XP pro and Apache. I can run the command fine from the
    command line, but it is not making it from perl. Is this a
    permissions issue? (how could I enable it)

    $command = "c:\\Progra~1\\HomeCo~1\\x10com32.exe";
    @args = ($command, "a4", "off");
    system(@args);

    I can type
    c:\Progra~1\HomeCo~1\x10com32.exe a4 off
    at the command line and it works fine, trying to get this command from
    a web page.

    I am getting through to windows cause this will work:
    system("dir e:\\www");

    any ideas

    thanks,
     
    CoralBanded, Jan 7, 2004
    #1
    1. Advertising

  2. CoralBanded wrote:
    >
    > I am trying to run a command from a web page using perl. The server
    > is Win XP pro and Apache. I can run the command fine from the
    > command line, but it is not making it from perl. Is this a
    > permissions issue? (how could I enable it)
    >
    > $command = "c:\\Progra~1\\HomeCo~1\\x10com32.exe";
    > @args = ($command, "a4", "off");
    > system(@args);
    >
    > I can type
    > c:\Progra~1\HomeCo~1\x10com32.exe a4 off
    > at the command line and it works fine, trying to get this command from
    > a web page.


    I'm no windows expert (quite to the contrary B-{), but maybe you need to
    spell out the directory names in full when running a command from within
    Perl?
    I.e.

    $command = "c:\\Program Files\\HomeControl\\x10com32.exe";
    @args = ($command, "a4", "off");
    system(@args);

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Möllers, Jan 7, 2004
    #2
    1. Advertising

  3. CoralBanded

    Thomas Kratz Guest

    CoralBanded wrote:
    > I am trying to run a command from a web page using perl. The server
    > is Win XP pro and Apache. I can run the command fine from the
    > command line, but it is not making it from perl. Is this a
    > permissions issue? (how could I enable it)
    >
    > $command = "c:\\Progra~1\\HomeCo~1\\x10com32.exe";
    > @args = ($command, "a4", "off");
    > system(@args);
    >
    > I can type
    > c:\Progra~1\HomeCo~1\x10com32.exe a4 off
    > at the command line and it works fine, trying to get this command from
    > a web page.
    >
    > I am getting through to windows cause this will work:
    > system("dir e:\\www");


    What about

    system("dir "c:\\Progra~1\\HomeCo~1");

    Do you see the executable's path in you CGI(?) script?
    I would guess apache restricts you (or XP restricts the user apache is
    running under) to cetrain directories.

    Not that this has anything to do with perl.

    See:
    perldoc -q browser

    Thomas
    --
    open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
    STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
    print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
    &&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..
     
    Thomas Kratz, Jan 7, 2004
    #3
  4. CoralBanded

    Hobbit HK Guest

    Josef Möllers <> wrote in message news:<>...
    > I'm no windows expert (quite to the contrary B-{), but maybe you need to
    > spell out the directory names in full when running a command from within
    > Perl?
    > I.e.


    Or maybe there's no spaces between the args and the command is linked..
    ie

    $cmd="dir";
    $arg="c:";
    @args=($cmd,$arg);
    system(@args);

    is like

    $cmd="dir";
    $arg="c:";
    system($cmd$arg);

    ?
     
    Hobbit HK, Jan 7, 2004
    #4
  5. Hobbit HK wrote:
    >
    > Josef Möllers <> wrote in message news:<>...
    > > I'm no windows expert (quite to the contrary B-{), but maybe you needto
    > > spell out the directory names in full when running a command from within
    > > Perl?
    > > I.e.

    >
    > Or maybe there's no spaces between the args and the command is linked..
    > ie
    >
    > $cmd="dir";
    > $arg="c:";
    > @args=($cmd,$arg);
    > system(@args);
    >
    > is like
    >
    > $cmd="dir";
    > $arg="c:";
    > system($cmd$arg);


    You mean system(@args) == system($cmd$arg)? Have you tried that?

    % perl
    $cmd="ls";
    $arg=".";
    @args=($cmd, $arg);
    system(@args);
    ^D
    host_a host_c shutdown-all test_on_off3.pl
    host_b host_d test_on_off2.pl test_on_off.pl
    % perl
    $cmd="ls";
    $arg=".";
    @args=($cmd, $arg);
    system($cmd$arg);
    ^D
    Scalar found where operator expected at - line 4, near "$cmd$arg"
    (Missing operator before $arg?)
    host_a host_c shutdown-all test_on_off3.pl
    host_b host_d test_on_off2.pl test_on_off.pl

    This is on a Linux box, but that should not matter.


    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Möllers, Jan 7, 2004
    #5
  6. Hobbit HK <> wrote:

    > $cmd="dir";
    > $arg="c:";
    > @args=($cmd,$arg);
    > system(@args);
    >
    > is like
    >
    > $cmd="dir";
    > $arg="c:";
    > system($cmd$arg);



    They are not alike.

    The 1st one is written in Perl, the 2nd one is not written in Perl.

    If you insteand meant: system("$cmd$arg"), then they are still
    not alike, the 1st one will never invoke a shell, the 2nd one might.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 7, 2004
    #6
  7. CoralBanded

    CoralBanded Guest

    Thomas Kratz <> wrote in message news:<>...
    > CoralBanded wrote:
    > > I am trying to run a command from a web page using perl. The server
    > > is Win XP pro and Apache. I can run the command fine from the
    > > command line, but it is not making it from perl. Is this a
    > > permissions issue? (how could I enable it)
    > >
    > > $command = "c:\\Progra~1\\HomeCo~1\\x10com32.exe";
    > > @args = ($command, "a4", "off");
    > > system(@args);
    > >
    > > I can type
    > > c:\Progra~1\HomeCo~1\x10com32.exe a4 off
    > > at the command line and it works fine, trying to get this command from
    > > a web page.
    > >
    > > I am getting through to windows cause this will work:
    > > system("dir e:\\www");

    >
    > What about
    >
    > system("dir "c:\\Progra~1\\HomeCo~1");
    >
    > Do you see the executable's path in you CGI(?) script?
    > I would guess apache restricts you (or XP restricts the user apache is
    > running under) to cetrain directories.
    >
    > Not that this has anything to do with perl.
    >
    > See:
    > perldoc -q browser
    >
    > Thomas


    system("dir "c:\\Progra~1\\HomeCo~1");
    works (removed the " in front of c:), assume that its apache does not
    have access to execute program? not sure how to enable that in
    XP?????
     
    CoralBanded, Jan 8, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Irmen de Jong
    Replies:
    2
    Views:
    437
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=
    Aug 12, 2003
  2. Dan M
    Replies:
    5
    Views:
    449
    Magnus Lycka
    Dec 14, 2005
  3. Robert La Ferla
    Replies:
    8
    Views:
    142
  4. Replies:
    2
    Views:
    165
    Tad McClellan
    Mar 26, 2005
  5. vikrant
    Replies:
    5
    Views:
    111
Loading...

Share This Page