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

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

    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
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    Originally posted by RaviRajhulk
    I need to call a batch file for execution through the perl script.pz help
    Use system command.
    [CODE=text]

    system("start C:\\Temp\\mybat chfile.bat"); # run the batch file
    sleep 15; ### wait 15s for execution before proceeding

    [/CODE]
    Last edited by nithinpes; Feb 22 '08, 04:25 AM. Reason: corrected typo

    Comment

    • eWish
      Recognized Expert Contributor
      • Jul 2007
      • 973

      #3
      Please read the "Guidelines To Ensuring Better Answers and Assistance To Your Thread(s)"

      --Kevin

      Comment

      • vibhakhushi
        New Member
        • Mar 2010
        • 33

        #4
        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:Document s\. How to fix this error?

        Comment

        • nithinpes
          Recognized Expert Contributor
          • Dec 2007
          • 410

          #5
          If the path contains spaces, then the entire path needs to be escaped within quotes (quoted command should be passed to system).

          Code:
          system("start \"C:\\Documents and Settings\\mybatchfile.bat\"");

          Comment

          • vibhakhushi
            New Member
            • Mar 2010
            • 33

            #6
            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?

            Comment

            • aksindia

              #7
              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.

              Comment

              Working...