Dear monks, I am attempting to write a script using two input files. Would the below code to it for me, or should I wirte it in a different form? Any input is greatly appreciated.
system 'cat temp3 | grep "hdlcppp" > hdlc1'; system "mv hdlc1 hdlc"; system 'cat hdlc | cut -d " " -f2-3 > hdlc1'; system "mv hdlc1 hdlc"; system 'cat hdlc | cut -d " " -f1 > hdlc1'; system 'cat hdlc | cut -d " " -f2 > hdlc2'; system "rm hdlcget"; open(HDCLGET, ">hdlcget"); print HDLCGET "\#\!\/usr\/local\/bin\/expect\n"; print HDLCGET "set timeout -1\n"; open(MYINPUTFILE, "hdlc1"); while(<MYINPUTFILE>) { my($line) = $_; chomp($line); print HDLCGET "spawn \ ssh $line\n"; print HDLCGET "expect \"assword: \"\n"; print HDLCGET "send \"password\\r\"\n"; print HDLCGET "expect \"#\"\n"; print HDLCGET "send \"terminal length 0\\r\"\n"; print HDLCGET "expect \"#\"\n"; open(MYINPUTFILE1, "hdlc2"); while(<MYINPUTFILE1>) { my($line1) = $_; chomp($line1); print HDLCGET "show xconnect all | inc $line1\\r\"\nexpect \"# +\"\n"; } } print HDLCGET "send \"exit\\r\"\n"; print HDLCGET "interact\n"; system "touch hdlcget"; system "chmod 777 hdlcget"; system "hdlcget >hdlc3";
Another idea I was considering was to just leave everytihng in the original file (hdlc) and then write the script so it uses field one of "$line" for the first input and field two for the second, but I have yet to figure out how to get that to work as well.

In reply to using multiple input files by ddrew78

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.