Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > external programm execution not possible...

Reply
Thread Tools

external programm execution not possible...

 
 
Michael
Guest
Posts: n/a
 
      12-29-2005
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/';
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      12-29-2005
Michael wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM
remoting programm execution in another computer using win32com mechatronic Python 0 06-20-2007 09:38 AM
Access to process memory from external programm TIM C Programming 6 04-12-2004 01:17 PM
Help!!! Loosing SessionState when calling external programm Freddy Fischer ASP .Net 1 10-23-2003 05:32 PM
Java Programm into Systray AlexPain Java 5 08-05-2003 08:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57