Reputation: 12777
Looking to open a file at '"E:\\Program Files (x86)\\Vim\\vim73\\gvim.exe -f " %s" "'
and I'm getting Cannot find e:\Program
.
What do I need to do to get it to work?
edit: Here's the script I am trying to get working (it's the full script as I'm not yet familar with perl at all, sorry). It's supposed to launch gvim when I make a POST request to the server via chrome's TextAid. Check out line 38
Upvotes: 1
Views: 941
Reputation:
our $EDITOR_CMD = "'E:\\Program Files (x86)\\Vim\\vim73\\gvim.exe' -f %s";
Upvotes: 0
Reputation: 27234
One way to handle this is to mess about with quoting and escapes. You need to be sure to individually quote the command and each argument to the command as a separate string.
Also, on win32 you can use real slashes instead of backslashes for directory separators. So:
system( sprintf '"E:/Program Files (x86)/Vim/vim73/gvim.exe" -f "%s"', $file );
The other, easier option is to use a list of arguments with system()
.
Line 38:
my @EDITOR_COMMAND = ( 'E:/Program Files (x86)/Vim/vim73/gvim.exe', '-f' );
Line 185/186:
system( @EDITOR_COMMAND, $file );
Then all the pesky quoting is taken care of for you.
Upvotes: 0
Reputation: 3631
I find it safer/easier to use forward slashes.
my $file = 'C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe' ;
system $file ;
If you need parameters to the cmmmond
my $file = '"C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe"' ;
my $data = '"C:\working_dir/music/interim/a b.pdf"' ;
system "$file $data" ;
Using single quotes makes it easier to embed double quites without having to escape things.
Upvotes: 1
Reputation: 386696
system
sprintf
'"E:\\Program Files (x86)\\Vim\\vim73\\gvim.exe" -f "%s"',
$file;
Upvotes: 1
Reputation: 12633
It's either single\double-quoting the path or escaping the spaces with backslashes.
Upvotes: 1