This one will drive me crazy. I have multiple input files, all containing the same number of lines. What I need to do is use all "line one" inputs, then all "line two" inputs, etc. While the below code does what it is supposed to with the last file, it never moves to line 2 of the first file. Any ideas?
print HDLCGET "\#\!\/usr\/local\/bin\/expect\n"; print HDLCGET "set timeout -1\n"; open(MYINPUTFILE, "hdlc2"); open(MYINPUTFILE1, "hdlc3"); while(<MYINPUTFILE>) { my($line) = $_; chomp($line); while(<MYINPUTFILE1>) { my($line1) = $_; chomp($line1); print HDLCGET "spawn \ ssh $line\n"; print HDLCGET "expect \"assword: \"\n"; print HDLCGET "send \"$tacacspw\\r\"\n"; print HDLCGET "expect \"#\"\n"; print HDLCGET "send \"terminal length 0\\r\"\n"; print HDLCGET "expect \"#\"\n"; print HDLCGET "send \"show xconnect all | inc $line1\\r\"\nexp +ect \"#\"\n"; print HDLCGET "send \"exit\\r\"\n"; print HDLCGET "interact\n"; } } close(MYINPUTFILE); close(MYINPUTFILE1);
Here is what I get from that code, I noted the inputs and the error:
#!/usr/local/bin/expect set timeout -1 spawn ssh 10.247.17.141 <-- line 1 of hdlc2 expect "assword: " send "tacacspw\r" expect "#" send "terminal length 0\r" expect "#" send "show xconnect all | inc 99999999\r" <--line 1 of hdlc3 expect "#" send "exit\r" interact spawn ssh 10.247.17.141 <--LINE 1 OF hdlc2, SHOULD BE LINE 2 expect "assword: " send "Kalewi13\r" expect "#" send "terminal length 0\r" expect "#" send "show xconnect all | inc 616698950\r" <--line 2 of hdlc3 expect "#" send "exit\r" interact
Also, while I'm using 2 input files here, later on I will have to use 4 input files, but I haven't gotten to that part yet, and I figured the same logic should apply

In reply to Using multiple input files #2 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.