Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run external program - Windows

Status
Not open for further replies.

gerschwin

Technical User
Jan 18, 2004
22
GB
Hi all

I'm trying to run an external app from within another perl script and want to do something like the following:

my $working_dir = "C:\Documents and Settings\somedir\";
exec ($working_dir.'myprogram.exe');

If I do it that way aroung then exec doesn't parse the spaces in the sting correctly. I've tried escaping them but same problem.
If I ran exec (cd, $working_dir); then it would work.

Whats the best way to achieve this?

Thanks
 
I don't really understand your statements but using backslashes in a double quoted string in Perl is generally a very bad idea.
You could escape all the backslashes or (possibly preferrably) swap them for forward slashes.


Trojan.
 
Use single quotes, but I prefer the feedback for using backticks
Code:
@results=`$cmd`;

but that's just me ;-)

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top