From leroy.tennison at verizon.net Tue Oct 7 00:00:10 2014 From: leroy.tennison at verizon.net (Leroy Tennison) Date: Tue, 07 Oct 2014 00:00:10 -0500 Subject: [NTLUG:Discuss] Scripting help In-Reply-To: <54262612.8070204@verizon.net> References: <201409261503.s8QF35Gm010835@egsner.cirr.com> <54262612.8070204@verizon.net> Message-ID: <5433735A.7040804@verizon.net> Eric's approach worked, thanks: hostlist="" while read host; do hostlist="$hostlist $host"; done (paste the line-delimited lists of hosts followed by a Ctrl-D here) for i in $hostlist; do telnet $i; done On 09/26/2014 09:50 PM, Leroy Tennison wrote: > Thanks for your reply. In response to your first question, the script > is hosted on the system I'm connecting to via ssh. More specifically, > the local host is Windows, the ssh client is Putty and only the remote > system is Linux. I do not have file system write access on the Linux > machine which makes things challenging. I write the script > interactively, pasting in my list at the appropriate place. > > I "played around" with your final script and may have come up with a > solution: > > hosts="host1 > host2 > host3"; > for i in $hosts; do echo aaa $i bbb; done (I'm testing > from home where no host list exists so 'echo aaa $i bbb' shows the > command) > > What I got was: > > aaa host1 bbb > aaa host2 bbb > aaa host3 bbb > > which looks like what I want. A test Monday will tell... > > On 09/26/2014 10:03 AM, Eric Schnoebelen wrote: >> Leroy Tennison writes: >> - I'm trying to get telnet to repetitively connect to a >> newline-delimited >> - list of devices. In other words, if I have device1, device2 and >> device3 >> - then what I want is: >> - >> - telnet device1 >> - telnet device2 >> - telnet device3 >> - >> - I've used three devices as an example but my lists are much longer. >> For >> - reasons too complicated to go into, this has to be done via ssh to a >> - Linux machine where I have no file system access (so the list has >> to be >> - pasted into the script interactively). >> >> Is the script hosted locally or on the system you're using SSH >> to connect too? >> >> If the script, and the list of devices are in files locally, >> something like this could work: >> >> for h in host1 host2.. ; do >> ssh gateway telnet $h >> done >> >> If the script is remote, but can take an argument set (aka, it >> looked like this: >> for h in "$@"; do >> telnet $h >> done >> ) >> >> it could be called as >> >> ssh gateway