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>
1
  • Adding comment to the original post...
    – Numpty
    May 26, 2012 at 23:08

3 Answers 3

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
1
  • 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, 2012 at 1:55
0

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

5
  • 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, 2012 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). May 26, 2012 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, 2012 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 May 26, 2012 at 23:32
  • IP Tables block it unless you're accessing it from localhost...but thanks
    – Numpty
    May 27, 2012 at 1:52
0

alternatively using xterm:

#!/usr/bin/env bash
for i in {2001..2004};do xterm -e telnet localhost $i &;done
1
  • thanks, but no one really likes xterm, right? :)
    – Numpty
    May 27, 2012 at 2:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .