Perl system command not executing

C

CoralBanded

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,
 
J

Josef Möllers

CoralBanded said:
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);
 
T

Thomas Kratz

CoralBanded said:
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
 
H

Hobbit HK

Josef Möllers said:
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);

?
 
J

Josef Möllers

Hobbit said:
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.
 
T

Tad McClellan

Hobbit HK said:
$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.
 
C

CoralBanded

Thomas Kratz said:
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?????
 

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,145
Messages
2,570,824
Members
47,369
Latest member
FTMZ

Latest Threads

Top