Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl system command not executing

Reply
Thread Tools

Perl system command not executing

 
 
CoralBanded
Guest
Posts: n/a
 
      01-07-2004
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,
 
Reply With Quote
 
 
 
 
Josef Möllers
Guest
Posts: n/a
 
      01-07-2004
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
 
Reply With Quote
 
 
 
 
Thomas Kratz
Guest
Posts: n/a
 
      01-07-2004
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^..
 
Reply With Quote
 
Hobbit HK
Guest
Posts: n/a
 
      01-07-2004
Josef Möllers <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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);

?
 
Reply With Quote
 
Josef Möllers
Guest
Posts: n/a
 
      01-07-2004
Hobbit HK wrote:
>
> Josef Möllers <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > 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
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      01-07-2004
Hobbit HK <(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
CoralBanded
Guest
Posts: n/a
 
      01-08-2004
Thomas Kratz <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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?????
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl executing a command (on UNIX) gil Perl Misc 3 08-14-2007 12:38 PM
Pull out only first field of ps command ( in Perl ) PERL RUN COMMAND tweetiebirds@gmail.com Perl Misc 2 03-26-2005 06:03 AM
Problem with executing UNIX command in perl script sunil Perl Misc 2 12-25-2003 04:03 AM
Perl CGI executing command line functions Nick Perl Misc 14 10-03-2003 03:05 PM
os.system('cd dir1 ... and executing next os.system command in that directory (dir1) Irmen de Jong Python 2 08-12-2003 12:43 PM



Advertisments