By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,845 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,845 IT Pros & Developers. It's quick & easy.

How to Call a Batch file for execution from a perl script

P: 12
I need to call a batch file for execution through the perl script.pz help
Feb 22 '08 #1
Share this Question
Share on Google+
6 Replies


nithinpes
Expert 100+
P: 410
I need to call a batch file for execution through the perl script.pz help
Use system command.
Expand|Select|Wrap|Line Numbers
  1.  
  2. system("start C:\\Temp\\mybatchfile.bat");   # run the batch file
  3. sleep 15;  ### wait 15s for execution before proceeding
  4.  
  5.  
Feb 22 '08 #2

eWish
Expert 100+
P: 971

P: 33
Hello, nithinpes i am trying to run a batch file which is located in Documents and Settings folder. I get the error as windows can not find the path "c:Documents\. How to fix this error?
Sep 23 '10 #4

nithinpes
Expert 100+
P: 410
If the path contains spaces, then the entire path needs to be escaped within quotes (quoted command should be passed to system).

Expand|Select|Wrap|Line Numbers
  1. system("start \"C:\\Documents and Settings\\mybatchfile.bat\"");
  2.  
  3.  
Sep 23 '10 #5

P: 33
Thank you nithinpes. I have small doubt. Should the batch be in C folder only to be executed? Cos I have my batch file in D drive. When i try to run batch file individually, it runs and gives me corresponding output. But, when I try to run from perl script, it wont run. Also, I wont get any error message. What might be the problem?
Sep 24 '10 #6

P: n/a
when the path contains spaces, replace the folder names with their windows names.
To get windows names of the folders, just use command dir /x.
it will solve spaces problem.
Oct 7 '10 #7

Post your reply

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