How to pass commands in Perl script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amareesh
    New Member
    • Oct 2015
    • 2

    #1

    How to pass commands in Perl script?

    Hi All,

    I'm new to perl and still learning.
    I'm having few files in a unix server which are actually in un-readable format. Those files are generated by some COBOL programs and those files are of RECORD TYPE 31.

    Normally we used to give below command manually to read these files in the Unix server.

    > irs "filename"

    Then it will open vi editor and will display the file in readable format (TXT format). Then we are passing ":q!" to come out of this editor. After this a text file will be generated in the directory which is what we need.

    Now I want to implement these steps using perl script. I tried using system() and backticks`` to do this, but the perl script is waiting for the quitr command to get out of that vi editor. Please help me in how to pass those commands through perl script.

    Code:
    #!/usr/local/bin/perl
    use File::Copy;
    @outarray = ();
    @outarray = `ls \*.INT.\*`;
    print "@outarray \n";
    foreach $outint (@outarray){
    system("irs $outint");
    }
    exit;
    When I execute this script, it is opening vi editor and I can able to see the readable format of the file, but I should give quit command manually to come out of that, but I need that to be done through script.
    Let me know if any details required from my end.
    Last edited by Amareesh; Oct 1 '15, 01:29 PM. Reason: Corrected few information.
  • Amareesh
    New Member
    • Oct 2015
    • 2

    #2
    Hi All,
    Can any one help me in this please?

    Comment

    Working...