471,862 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,862 software developers and data experts.

Problem with system command on Windows


I want to do following operations:

1. Execute exe from perl script.
I am using following code:

system ("start \.\.\\Client\.exe");

Perl script is one directory up the directory where Client.exe is present.
My problem is that the it starts the client.exe with error. Actually the libraries that i have called in the exe program are not getting executed( or called).
I compiled Winbatch script to get Client.exe.

2. Open Outlook using perl script.

system ("start C:\\Program Files\\Microsoft Office\\outlook\.exe");

It gives an error saying system can not find the file "C;\Progrm".
Even if I use

system ("start C:\\Program\s Files\\Microsoft\sOffice\\outlook\.exe");

I gives an error: system can not find the file
"C;\ProgrmsFiles\MicrosoftsOffice\outlook.exe" .

Any direction to solve the problem would ba a great help.
Aug 23 '07 #1
5 23571
3,503 Expert Mod 2GB
First, I am going to assume that you are operating on a Windows operating system. That said, you are not escaping all of the spaces or other special characters. Take a look at this quick script that I just put together and tested. This worked fine:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  4. system("c:\\Program\ Files\\Microsoft\ Office\\OFFICE11\\Outlook.exe");
As you can see, not only did I double slash the entire path, but I also slash escaped the spaces in "Program Files" and "Microsoft Outlook". This is a must do to get that working.


Aug 23 '07 #2
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. $dpath="\"C:\\Program Files\\VMware\\VMware Workstation\"";
  3. $vmdpath="\"C:\\Users\\vijay\\Documents\\Virtual Machines\"";
  4. printf "Enter the name of VM:";
  5. $name=<STDIN>;
  6. chomp $name;
  7. $cmd="$dpath\\vmrun start $vmdpath\\$name\\$name.vmx";
  8. system $cmd;
I was able to solve the issue of space in between "Program Files" & "VMware Workstation" using guidelines given above but when I ask user to enter the name of VM & if this "name" contains space like "suse linux 10.2" etc then again I am getting stuck at the same problem mentioned above
Nov 4 '07 #3
971 Expert 512MB
I would try this and see if it help your issue. Also use the strict pragma.

Expand|Select|Wrap|Line Numbers
  1. my $dpath=q{C:\\Program Files\\VMware\\VMware Workstation};
The q{} is like a single quote. If you use qq{} it is like using double quotes.
Nov 4 '07 #4
hi ..

this single line code is working well ...

system ("C:\\Program Files\\Microsoft Office\\office\\outlook.exe");

system ("C:\\Program Files\\Microsoft Office\\office\\POWERPNT.EXE");

I checked....

Check the path ...
Nov 5 '07 #5
4,059 Expert 2GB
You should be doing this:

Expand|Select|Wrap|Line Numbers
  1. my $cmd = 'C:/Program Files/Microsoft Office/office/outlook.exe';
  2. system($cmd);
Windows uses forward slashes or backslashes in directory paths, but backslashes in perl are meta characters and just confuse the issues when used needlessly. Also, use the correct quotes for the situation.
Nov 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Xah Lee | last post: by
36 posts views Thread by AussieRules | last post: by
3 posts views Thread by f1racing24 | last post: by
3 posts views Thread by Geraldine Hobley | last post: by
1 post views Thread by tassieboy | last post: by
2 posts views Thread by gg9h0st | last post: by
5 posts views Thread by =?Utf-8?B?Z215ZXJz?= | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.