Rijwan has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I want to execute (silk test .exe) through my perl script on windows. But its not working...it may be because of space (between file path) or arguments passed..

Currently I have written like this -
system("C:\\Program files\\Borland\\SilkTest\\partner.exe" -q -r "C:\\ +Perfrom_Acce\\Investigate\\Investigate_ACCEPTANCE.t" WelcomePagesOn);
If I execute the same command on dos prompt,it works.
"C:\\Program files\\Borland\\SilkTest\\partner.exe" -q -r "C:\\Perfrom +_Acce\\Investigate\\Investigate_ACCEPTANCE.t" WelcomePagesOn
Its giving me following error -
Bareword found where operator expected at t1.pl line 2, near ""C:\\Per +from_Acce\\Investigate\\Investigate_ACCEPTANCE. " WelcomePagesOn" (Missing operator before WelcomePagesOn?) String found where operator expected at t1.pl line 4, near "system("" (Might be a runaway multi-line "" string starting on line 2) (Missing semicolon on previous line?) Bareword found where operator expected at t1.pl line 4, near "system(" +C" Backslash found where operator expected at t1.pl line 4, near "Borland +\" Backslash found where operator expected at t1.pl line 4, near "SilkTes +t\" String found where operator expected at t1.pl line 4, near "exe" -r "" Bareword found where operator expected at t1.pl line 4, near "" -r "C" (Missing operator before C?) Backslash found where operator expected at t1.pl line 4, near "Perfrom +_Acce\" Backslash found where operator expected at t1.pl line 4, near "Investi +gate\" String found where operator expected at t1.pl line 4, at end of line (Missing semicolon on previous line?) syntax error at t1.pl line 2, near ""C:\\Program files\\Borland\\SilkT +est\\partner.exe" -r " Can't find string terminator '"' anywhere before EOF at t1.pl line 4.
Let me know how to proceed on the same.

Replies are listed 'Best First'.
Re: How to execute .exe from perl script
by almut (Canon) on Dec 03, 2008 at 13:19 UTC

    system() expects a string (or a list of strings) — not a mixture of whitespace-separated strings and barewords.

    system('"C:\\Program files\\Borland\\SilkTest\\partner.exe" -q -r "C:\ +\Perfrom_Acce\\Investigate\\Investigate_ACCEPTANCE.t" WelcomePagesOn' +);

    (note the single quotes around the entire command)

      Thanks it works...... sorry for not posting question effetely
Re: How to execute .exe from perl script
by Bloodnok (Vicar) on Dec 03, 2008 at 13:18 UTC