external programm execution not possible...

Discussion in 'Perl Misc' started by Michael, Dec 29, 2005.

  1. Michael

    Michael Guest

    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/';
     
    Michael, Dec 29, 2005
    #1
    1. Advertising

  2. Michael

    Paul Lalli Guest

    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
     
    Paul Lalli, Dec 29, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Freddy Fischer
    Replies:
    1
    Views:
    316
    Natty Gur
    Oct 23, 2003
  2. AlexPain

    Java Programm into Systray

    AlexPain, Jul 30, 2003, in forum: Java
    Replies:
    5
    Views:
    1,500
    Eugene Toporov
    Aug 5, 2003
  3. Romeo
    Replies:
    3
    Views:
    373
    Mickey Segal
    Nov 13, 2003
  4. TIM
    Replies:
    6
    Views:
    416
    Christopher Benson-Manica
    Apr 12, 2004
  5. mechatronic
    Replies:
    0
    Views:
    355
    mechatronic
    Jun 20, 2007
Loading...

Share This Page