I'm on Windows :-/ and in my script i've:
$ENV{'Powmig Path'}powermt
That give me:
C:\Program\ Files\EMC\PowerPath\powermt
if I do a if(-e $ENV{'Powmig Path'}powermt)
it doesn't work.
I have try to change my path with some substitution \ /
I have also try to add more double quote but nothing seems to work :-(
Exemple:
#!/usr/bin/perl
use strict;
use warnings;
use File::Spec;
if($^O =~ m/^MSWin32$/){
my $tmp = File::Spec->catdir($ENV{'Powmig Path'}, "powermt");
if(-e "\"$tmp\""){
print "powermt found\n";
}else{
print "No multipathing found \"$tmp\"\n";
}
$tmp =~ s/\\/\//g;
if(-e "\"$tmp\""){
print "powermt found\n";
}else{
print "No multipathing found \"$tmp\"\n";
}
}else{
print "Error: Unknow OS\n";
}
exit;
Output:
C:\Users\sgargasson\Desktop>perl test.pl
No multipathing found "C:\Program Files\EMC\PowerPath\powermt"
No multipathing found "C:/Program Files/EMC/PowerPath/powermt"
After some try with different files, the problem comming from the space...
Can somebody help me?
Thx in Adv
Here's a problem:
You've got an extra set of quotes. The filename isn't
"C:\Program Files\whatever"
, it'sC:\Program Files\whatever
. You only want those extra quotes if the filename is being interpreted by the Command Prompt, or something like that, and that's not the case here.Try this instead, where I've removed the extraneous quotes (
"\"$tmp\""
becomes"$tmp"
, which is exactly the same as$tmp
):You do realize that you cannot just type a string into the source code, right? You need to quote it:
This will interpolate the variable, in this case a hash value from the hash
%ENV
, and concatenate it with the stringpowermt
.And if you do try to concatenate a string to a variable, you first need to quote it, and then use an operator to attach it to the variable:
If you are trying to build paths, though, you might use a module suitable for that task, such as
File::Spec
:Thanks a LOT to TLP
I'm so a stupid linux user!!!!
PROBLEM:
SOLVE:
CORRECT CODE IS:
I'm so stupid, I need to uncheck "Hide know extension" So many hours in this things...