external programm execution not possible...

M

Michael

Hi,
my application reads several paths from a configruation file.
Some of these paths pointing to an executable which are to start
with an input file. Example: Adobe Reader with a pdf-file.

The executables are stored in c:\Program Files\...

When I try to execute the following, Perl is obvioulsy not able
to handle the spaces within the path information correctly and
aborts with
'c:/Programm' is not recognized as an internal or external command,
operable program or batch file

Does anyone know a solution or could help me?


perl-code:

use Config::Simple;

Initiale('cfgfile.ini');

################################################
sub Initialize {
################################################
my $cfgfile = shift;
my $cfg;

$cfg = new Config::Simple($cfgfile) or Error(20,[$cfg->error]);

# read path section

$p2adobe = $cfg->param("path.adobe");
$p2pdf = $cfg->param("path.pdf");


exec( $p2adobe.' '.$p2pdf.'test.pdf' );

} # Initialize



cfgfile.ini:


[path]
adobe = 'c:/Program Files/Adobe/Acrobat 7.0/Reader/AcroRd32.exe';
pdf = 'e:/PDF/';
 
P

Paul Lalli

Michael said:
my application reads several paths from a configruation file.
Some of these paths pointing to an executable which are to start
with an input file. Example: Adobe Reader with a pdf-file.

The executables are stored in c:\Program Files\...

When I try to execute the following, Perl is obvioulsy not able
to handle the spaces within the path information correctly and
aborts with
'c:/Programm' is not recognized as an internal or external command,
operable program or batch file

It's not Perl that can't handle it. It's your shell. Try typing that
path exactly on the command line, see what happens.
Does anyone know a solution or could help me?

This question has come up about three different times in the last
month. Please search the archives.

Short answer: Quote your path, escape the spaces, or use the multi-arg
form of exec/system to avoid the shell altogether.
system(q{ "C:\Program Files\Adobe\Reader.exe" file.pdf } );
or
system(q{C:\Program\ Files\Adobe\Reader.exe file.pdf});
or
system(q{C:\Program Files\Adobe\Reader.exe}, q{file.pdf});

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top