471,886 Members | 1,068 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 23888
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
  2. system("start C:\\Temp\\mybatchfile.bat");   # run the batch file
  3. sleep 15;  ### wait 15s for execution before proceeding
Feb 22 '08 #2
971 Expert 512MB
Please read the "Guidelines To Ensuring Better Answers and Assistance To Your Thread(s)"

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
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\"");
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | 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.