469,366 Members | 2,386 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.

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

I need to call a batch file for execution through the perl script.pz help
Feb 22 '08 #1
6 23086
nithinpes
410 Expert 256MB
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
971 Expert 512MB
Please read the "Guidelines To Ensuring Better Answers and Assistance To Your Thread(s)"

--Kevin
Feb 22 '08 #3
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
410 Expert 256MB
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
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
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.

Similar topics

3 posts views Thread by SeeBelow | last post: by
reply views Thread by KMiller | last post: by
3 posts views Thread by hughie | last post: by
2 posts views Thread by lilly07 | 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.