1

I'm just curious if this is possible. I'm working with dynagen/qemu rather frequently (CCIE training), and would love to be able to run script 'x' to open 10 windows for me, all telnet'd to predefined ports.

IE:

new gnome-terminal opens -> telnet localhost 2001
new gnome-terminal opens -> telnet localhost 2002
new gnome-terminal opens -> telnet localhost 2003
new gnome-terminal opens -> telnet localhost 2004

etc,

I've done my fair share of googlin' and can't seem to come up with a straight answer.

Thanks for the help :)

Edit: This is how it's listening right now:

root@NiXToP:/home/***# netstat -na |grep 2001
tcp        0      0 0.0.0.0:2001            0.0.0.0:*               LISTEN    
root@NiXToP:/home/***# netstat -na |grep 2002
tcp        0      0 0.0.0.0:2002            0.0.0.0:*               LISTEN 
root@NiXToP:/home/***# netstat -na |grep 2003
tcp        0      0 0.0.0.0:2003            0.0.0.0:*               LISTEN

What telnet currently accomplishes:

# telnet localhost 2001
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connected to Dynamips VM "R1" (ID 0, type c3725) - Console port
R1>
mgorven
  • 30,615
  • 7
  • 79
  • 122
Numpty
  • 113
  • 1
  • 4

3 Answers3

2

You can use the -x or -e options to run gnome-terminal and execute a specified command. For example:

gnome-terminal -x telnet miku.acm.uiuc.edu

So your script would execute gnome-terminal with the appropriate commands. If your port numbers are sequential you could do this with a loop:

#!/bin/sh
for PORT in $(seq 2001 2010); do
    gnome-terminal -x telnet localhost $PORT &
done
mgorven
  • 30,615
  • 7
  • 79
  • 122
  • Works like a charm - thank you sir. Unfortunately it doesn't work for the ASAs since they are...special it seems. I'll get by with an alias for those. Thanks again! – Numpty May 27 '12 at 01:55
0

Did you try clusterssh? It is available in Ubuntu as clusterssh

Raymond Tau
  • 682
  • 3
  • 16
  • I don't think that's going to work tbh, unless you know something that I don't. How would you SSH to a local port without authenticating (Can you even use SSH keys on localhost??) – Numpty May 26 '12 at 23:07
  • I can't think of a reason PubKey authentication does not work on localhost. After all, it is just another TCP connection and the PubKey authentication happens over that. In addition, it works even if you do not use PubKey authentication, as you can switch to each individual ssh window to type your password in (assume the althernative to PubKey authentication is Password). – Raymond Tau May 26 '12 at 23:17
  • I'd also have to configure sshd to listen on those ports, and I'm not entirely sure it will tunnel it to dynamips either. I need to use telnet – Numpty May 26 '12 at 23:26
  • Sorry. I didn't notice you are talking about telnet, which I think should not be enabled by all mean. Anyway, clusterssh works with telnet as well, just use the command "ctel" after you install clusterssh – Raymond Tau May 26 '12 at 23:32
  • IP Tables block it unless you're accessing it from localhost...but thanks – Numpty May 27 '12 at 01:52
0

alternatively using xterm:

#!/usr/bin/env bash
for i in {2001..2004};do xterm -e telnet localhost $i &;done
Jodie C
  • 743
  • 6
  • 9