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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RaviRajhulk
    New Member
    • Feb 2008
    • 12

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

    I have tried executing executing a batch file from a perl code using
    system("start c:\\temp\\sampl e.bat")
    but it is not executing ,Is there any way to execute batch file from a perl code
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    Originally posted by RaviRajhulk
    I have tried executing executing a batch file from a perl code using
    system("start c:\\temp\\sampl e.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:
    Code:
    system("start c:\\temp\\sample.bat");
    Is it throwing any error? That would help to find the cause.
    Though, you can alternatively use reverse quote( ` ) instead of system command.
    Code:
    `start c:\\temp\\sample.bat`;

    Comment

    • RaviRajhulk
      New Member
      • Feb 2008
      • 12

      #3
      Originally posted by nithinpes
      The way you have tried should ideally work:
      Code:
      system("start c:\\temp\\sample.bat");
      Is it throwing any error? That would help to find the cause.
      Though, you can alternatively use reverse quote( ` ) instead of system command.
      Code:
      `start c:\\temp\\sample.bat`;
      Its executing fine now with
      Code:
      `C:\temp\sample.bat`
      ,but another problem is occuring.....wh en 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

      Comment

      Working...