B
buildmorelines
I want to do backtick execution (to capture STDOUT to a variable for
matching/error handling) with a shell variable in it. If I type it
into a C prompt
C:\>"%PROGRAMFILES%\Windows Media Player\mplayer2.exe" #works fine
When I do
C:\>%PROGRAMFILES%\Windows Media Player\mplayer2.exe
I get
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Now if I do it in Perl as (heres a list of everything I tried)
system('%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe');
system("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
system("\%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
system'"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"';
`"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"`;
`\"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe\"`;
qx/"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"/;
qx!"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"!;
qx#"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"#;
qx("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
$run = '"%PROGRAMFILES%\Windows Media Player\mplayer2.exe"';
`$run`;
$run = '%PROGRAMFILES%\Windows Media Player\mplayer2.exe';
`$run`;
I get
'C:\Program' is not recognized as an internal or external command,
operable program or batch file
I've spent 3 hours trying to do this.
The only code I found that does it (written by myself), is this
totally crazy, and there has to be a better, more efficent way. It is
below.
#!/usr/bin/perl
$data = `echo %PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
chop $data;
$data = '"' . $data . '"';
print "\n data is \n\n $data \n\n";
`$data`;
Idealy I would like this to work.
$run_result = `%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
Also I know that I need to manually close Windows Media Player for all
of these to work but thats not the point and I have a solution for
that (cmd /c or start).
matching/error handling) with a shell variable in it. If I type it
into a C prompt
C:\>"%PROGRAMFILES%\Windows Media Player\mplayer2.exe" #works fine
When I do
C:\>%PROGRAMFILES%\Windows Media Player\mplayer2.exe
I get
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Now if I do it in Perl as (heres a list of everything I tried)
system('%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe');
system("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
system("\%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
system'"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"';
`"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"`;
`\"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe\"`;
qx/"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"/;
qx!"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"!;
qx#"%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe"#;
qx("%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe");
$run = '"%PROGRAMFILES%\Windows Media Player\mplayer2.exe"';
`$run`;
$run = '%PROGRAMFILES%\Windows Media Player\mplayer2.exe';
`$run`;
I get
'C:\Program' is not recognized as an internal or external command,
operable program or batch file
I've spent 3 hours trying to do this.
The only code I found that does it (written by myself), is this
totally crazy, and there has to be a better, more efficent way. It is
below.
#!/usr/bin/perl
$data = `echo %PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
chop $data;
$data = '"' . $data . '"';
print "\n data is \n\n $data \n\n";
`$data`;
Idealy I would like this to work.
$run_result = `%PROGRAMFILES%\\Windows Media Player\\mplayer2.exe`;
Also I know that I need to manually close Windows Media Player for all
of these to work but thats not the point and I have a solution for
that (cmd /c or start).