469,366 Members | 2,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

Problem with system command on Windows

shrek123
Hi,

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 23208
numberwhun
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;
  3.  
  4. system("c:\\Program\ Files\\Microsoft\ Office\\OFFICE11\\Outlook.exe");
  5.  
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.

Regards,

Jeff
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;
  9.  
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
eWish
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
savanm
85
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
KevinADC
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.