Connecting to command prompt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bunny02
    New Member
    • Dec 2006
    • 7

    Connecting to command prompt

    Hi all,

    I m new to perl, and writing a script , in which i need to connect to the command prompt from my perl script and pass some commands like " mkdir testdir".

    Is there any module available in perl to do this (in python we have os module) . I googled for it but i didnt get any help.

    If any one has idea, please reply asap.
    It's urgent.

    thanks in advance

    bunny
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    Originally posted by bunny02
    Hi all,

    I m new to perl, and writing a script , in which i need to connect to the command prompt from my perl script and pass some commands like " mkdir testdir".

    Is there any module available in perl to do this (in python we have os module) . I googled for it but i didnt get any help.

    If any one has idea, please reply asap.
    It's urgent.

    thanks in advance

    bunny
    Hi bunny,
    You don't need any module for this. Just put the DOS commands within reverse quotes( ` ).


    like:
    [CODE=text]
    `mkdir testdir`;
    [/CODE]

    will create the directory testdir. Reverse quote is used to execute system commands.

    Comment

    • bunny02
      New Member
      • Dec 2006
      • 7

      #3
      Hi Nithin

      Thanks for ur response, it works fine for me. :)

      rgds
      bunny


      Originally posted by nithinpes
      Hi bunny,
      You don't need any module for this. Just put the DOS commands within reverse quotes( ` ).


      like:
      [CODE=text]
      `mkdir testdir`;
      [/CODE]

      will create the directory testdir. Reverse quote is used to execute system commands.

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        hopefully nobody sends the command "del c:\" to your perl script. Direct unfiltered input of system commands is very dangerous.

        Comment

        • npidaparthy
          New Member
          • Feb 2008
          • 14

          #5
          Hi Bunny,

          inaddition to back quotes, you can also use 'system' as follows

          system('mkdir testdir');

          system will execute os commands from Perl

          -Nagendra Pidaparthy

          Originally posted by bunny02
          Hi all,

          I m new to perl, and writing a script , in which i need to connect to the command prompt from my perl script and pass some commands like " mkdir testdir".

          Is there any module available in perl to do this (in python we have os module) . I googled for it but i didnt get any help.

          If any one has idea, please reply asap.
          It's urgent.

          thanks in advance

          bunny

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #6
            Originally posted by bunny02
            H
            If any one has idea, please reply asap.
            It's urgent.
            Also, please know that putting "Its urgent" or "Its an emergency", does not get you help any faster. Everyone here are volunteers and are not bound by the urgencies that you are under. Its best to just ask your question(s) and wait for their answer(s) that are provided.

            Regards,

            Moderator

            Comment

            Working...