Perl backtick ignores everything past the first space

80 views Asked by At

I have a command

my $output = `somecommand parm1 parm2`;

When I try to run this Perl script I get the message

Can't exec "somecommand" at .....

It seems it is not seeing anything past the first space in between the backticks. I have a friend who runs this in a different environment and it runs fine.

What could I have in my environment that would cause this? I am running Perl v5.20 but so is my friend.

1

There are 1 answers

0
Borodin On

Perl's not ignoring the command parameters, it's just mentioning only the part of the command that it has a problem with -- it can't find somecommand

Whatever your somecommand is, it's not a shell command and it's not in a directory listed in your PATH variable

Change PATH to add its location to the end and it will work for you. You can do that system-wide or you dan modify it temporarily in your Perl code by manipulating $ENV{PATH} before you run the command