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

Executing a batch file(.bat) from a perl code

P: 12
I have tried executing executing a batch file from a perl code using
system("start c:\\temp\\sample.bat")
but it is not executing ,Is there any way to execute batch file from a perl code
Feb 26 '08 #1
Share this Question
Share on Google+
2 Replies


nithinpes
Expert 100+
P: 410
I have tried executing executing a batch file from a perl code using
system("start c:\\temp\\sample.bat")
but it is not executing ,Is there any way to execute batch file from a perl code
The way you have tried should ideally work:
Expand|Select|Wrap|Line Numbers
  1. system("start c:\\temp\\sample.bat");
  2.  
Is it throwing any error? That would help to find the cause.
Though, you can alternatively use reverse quote( ` ) instead of system command.
Expand|Select|Wrap|Line Numbers
  1. `start c:\\temp\\sample.bat`;
  2.  
Feb 27 '08 #2

P: 12
The way you have tried should ideally work:
Expand|Select|Wrap|Line Numbers
  1. system("start c:\\temp\\sample.bat");
  2.  
Is it throwing any error? That would help to find the cause.
Though, you can alternatively use reverse quote( ` ) instead of system command.
Expand|Select|Wrap|Line Numbers
  1. `start c:\\temp\\sample.bat`;
  2.  
Its executing fine now with
Expand|Select|Wrap|Line Numbers
  1. `C:\temp\sample.bat` 
  2.  
,but another problem is occuring.....when there is some error in the .bat file(sample.bat) the perl should not execute it,and should throw some error message,but in case of error in the .bat file also,it is executing........Is there any way to capture in the perl code that if there is some error in the sample.bat file then it should throw some error message and should not excute the .bat file
Feb 27 '08 #3

Post your reply

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