472,796 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

Can I do it using python?? about xterm and telnet

I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.

Any suggestion appreciate. Much thanks.

Jul 2 '06 #1
20 3859
In article <11*********************@b68g2000cwa.googlegroups. com>,
valpa <va********@gmail.comwrote:
>I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.
Don't use telnet. it's clumsy and has security issues.

Use ssh with RSA or DSA keys. Then you simply do:

ssh username@machine_name

in an xterm and you are loggedis as user username on server
machinename. It's vastly more secure and more reliable.

If you're talking about initial setup of a machine (OS installation or
whatever), our solution was to have a post-install CD or floppy which
fetched standard server configuration data. This included an ssh
public key for our ssh-key distribution, so after running the
post-install disc, we could push out staff ssh-keys and logins were
available.


--
Jim Segrave (je*@jes-2.demon.nl)

Jul 2 '06 #2

Jim Segrave wrote:
In article <11*********************@b68g2000cwa.googlegroups. com>,
valpa <va********@gmail.comwrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Don't use telnet. it's clumsy and has security issues.
if youre behind a firewall then it shouldnt matter.
>
Use ssh with RSA or DSA keys. Then you simply do:

ssh username@machine_name

in an xterm and you are loggedis as user username on server
machinename. It's vastly more secure and more reliable.

If you're talking about initial setup of a machine (OS installation or
whatever), our solution was to have a post-install CD or floppy which
fetched standard server configuration data. This included an ssh
public key for our ssh-key distribution, so after running the
post-install disc, we could push out staff ssh-keys and logins were
available.
I dont think the OP wants to do post-install configuration (i may be
wrong! ) but to change for example some config file.

You should be able to create a dictionary containing username=password,
then iterate over this dictionary and use os.system("xterm -e telnet -u
%s -p %s") where -u is username and -p is password (im not quite sure
if telnet has these arguments or if it works like this too)

Cheers

Jul 2 '06 #3
try pexpect.
http://pexpect.sourceforge.net/

valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.

Any suggestion appreciate. Much thanks.
Jul 2 '06 #4
try pexpect.
http://pexpect.sourceforge.net/

valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.

Any suggestion appreciate. Much thanks.
Jul 2 '06 #5

Just FYI - pexpect is a Python app that works like Expect - which is by
Don Libes and written in TCL. Expect comes with most Linux
distributions and is available for most UNIX / Linux versions from its
web site http://expect.nist.gov/

The expect man page is enough to get started for simple needs, such as
yours appears to be. You might want to play around with the original
Expect a bit and then try out pexpect - or you could just use Expect
itself for your needs.

HTH
Vasudev
---
Vasudev Ram
Independent software consultant
http://www.geocities.com/vasudevram
PDF conversion toolkit:
http://sourceforge.net/projects/xtopdf
---
faulkner wrote:
try pexpect.
http://pexpect.sourceforge.net/

valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.

Any suggestion appreciate. Much thanks.
Jul 2 '06 #6

valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.

I often have to add users/delete local user accounts on routers and
switches. Each account is a local account, and I got tired of it. My
very first python program was created to use the telnetlib, and either
add, delete, or show a list of user accounts. It was very effective,
because it would change the same accounts on each router and switch.
Saved me a bunch of time, and got me hooked on python. If you are not
concerned about security, the telnetlib in python will help you.
Otherwise, use ssh, as it is more secure. You can even impliment
public/private keys for password-less log on. If you want some help
with the code for the telnetlib, let me know.

Jul 2 '06 #7
I used this _EXACT_ solution(copied below) at work a month ago, to
start 20ish programs, each with different settings. In this case I HAD
to use telnet for some of them, because they were on an embedded
machine, 4 of them used SSH(across the internet), and the rest were
local programs. It worked flawlessly each time (every restart of the
network... which was quite often in this case). There may be more
integrated solutions which solve the problem, but expect is rediculousy
easy to use, and is very deterministic as long as the commands work.
If the commands fail to work (such as someone deletes your program),
debugging is rather difficult, but at least you have a full dump of
everything sent by the server (because pexpect prints it all to the
screen). Also, once the connection is open, you can call
conn.interact() and it will make the terminal interactive, just like
any other shell.
vasudevram wrote:
Just FYI - pexpect is a Python app that works like Expect - which is by
Don Libes and written in TCL. Expect comes with most Linux
distributions and is available for most UNIX / Linux versions from its
web site http://expect.nist.gov/

The expect man page is enough to get started for simple needs, such as
yours appears to be. You might want to play around with the original
Expect a bit and then try out pexpect - or you could just use Expect
itself for your needs.

HTH
Vasudev
---
Vasudev Ram
Independent software consultant
http://www.geocities.com/vasudevram
PDF conversion toolkit:
http://sourceforge.net/projects/xtopdf
---
faulkner wrote:
try pexpect.
http://pexpect.sourceforge.net/

valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.
>
Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.
>
Any suggestion appreciate. Much thanks.
Jul 2 '06 #8
In article <11*********************@b68g2000cwa.googlegroups. com>,
"valpa" <va********@gmail.comwrote:
>I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.
Do you need to replicate identical configurations to all the servers?

If so, perhaps you're approaching this the wrong way. A better solution
might be to look at replicating the config files directly to all
machines (using rsync, scp etc), rather than editing them in situ on
every single one.
Jul 3 '06 #9
In article <11**********************@j8g2000cwa.googlegroups. com>,
"placid" <Bu****@gmail.comwrote:
>Jim Segrave wrote:
>Don't use telnet. it's clumsy and has security issues.

if youre behind a firewall then it shouldnt matter.
Still not a good idea.
Jul 3 '06 #10
agreed, SSH is advisable over telnet in nearly all situations.
However, there are a few times where telnet is better.
1. Embeded machines often have stripped down OS's. Telnet is much
smaller and cheaper than a full blown SSH install. When every byte
counts, you wont find SSH
2. He may have a pre-existing network which his job does not allow him
to modify.

In either case, pexpect will do the job you need. Build the scripts
with pexpect, and then look into whether or not you can upgrade from
telnet to SSH. Converting a pexpect script from telnet to SSH is
trivial.

I've got a few scripts to do exactly what you are asking to do, from a
Gnome machine, along with an XML file to configure it. It spawns a
gnome multi-terminal with all the tabs, then telnets, ssh's, or
connects to the local machine, and runs a command. Once that command
is done, the window enters "interactive" mode and behaves just like any
other shell.

Are you at liberty to explain the network more fully? Mr. D'Oliveiro
makes an excelent point. When you're doing the same thing to a bunch
of machines, there's a good chance that a unix sysadmin has banged
his/her head on the table over the same problem, and wrote a program to
do this. Programs like rsync exist because of the challenges of
keeping multiple machine synchronized.

Annother option would be to do some creative mounting of NFS volumes.
A unix guru would be able to direct you to the most elegant solution

Jul 3 '06 #11
placid wrote:
Jim Segrave wrote:
In article <11*********************@b68g2000cwa.googlegroups. com>,
valpa <va********@gmail.comwrote:
>I'm a net admin for about 20 unix servers, and I need to frequently
>telnet on to them and configure them.
>It is a tiring job to open a xterm and telnet, username, password to
>each server.
Don't use telnet. it's clumsy and has security issues.

if youre behind a firewall then it shouldnt matter.
No, no, no! If you have 20 unix servers then this is likely not a tiny
company. Most security breaches (according to the FBI/CSI computer
crime survey) are perpetrated by insiders. If you log in using telnet,
and have to enter passwords that allow configurations to be changed,
then anyone on the local net can get those passwords. Use SSH instead.
Even SSH with passwords is hugely more secure than telnet.

Nicko

Jul 3 '06 #12
Thanks,

But I need to to do complicated job in the xterm consoles for servers.
So I need
to open many xterm consoles and I just want to save my time from
telneting...usr/pwd...

Network Ninja wrote:
valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.

Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.


I often have to add users/delete local user accounts on routers and
switches. Each account is a local account, and I got tired of it. My
very first python program was created to use the telnetlib, and either
add, delete, or show a list of user accounts. It was very effective,
because it would change the same accounts on each router and switch.
Saved me a bunch of time, and got me hooked on python. If you are not
concerned about security, the telnetlib in python will help you.
Otherwise, use ssh, as it is more secure. You can even impliment
public/private keys for password-less log on. If you want some help
with the code for the telnetlib, let me know.
Jul 3 '06 #13
I can get to my code on wednesday, I'll upload it somewhere you can get
a copy of it. But do look into using SSH, because in the long run it
is a far better tool. A properly configured SSHD also opens the way to
scp. Without scp, copying files means ftp, or unsecured rsync.

Do you want tabbed windows, or just a distinct xterm for each?
valpa wrote:
Thanks,

But I need to to do complicated job in the xterm consoles for servers.
So I need
to open many xterm consoles and I just want to save my time from
telneting...usr/pwd...
Jul 3 '06 #14
I don't care about security issue by now :), because every one in my
compony know the username/password. It's a shared password. I just want
to login into Unix boxes in an efficiently. so I needn't open a xterm
console and type telent ..... usr/pwd for a unix box, and open another
xterm, type telnet ...usr/pwd, and so on...
Nicko wrote:
placid wrote:
Jim Segrave wrote:
In article <11*********************@b68g2000cwa.googlegroups. com>,
valpa <va********@gmail.comwrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to
each server.
>
Don't use telnet. it's clumsy and has security issues.
if youre behind a firewall then it shouldnt matter.

No, no, no! If you have 20 unix servers then this is likely not a tiny
company. Most security breaches (according to the FBI/CSI computer
crime survey) are perpetrated by insiders. If you log in using telnet,
and have to enter passwords that allow configurations to be changed,
then anyone on the local net can get those passwords. Use SSH instead.
Even SSH with passwords is hugely more secure than telnet.

Nicko
Jul 3 '06 #15
"valpa" <va********@gmail.comwrites:
Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.
Have python launch "xterm -e somecommand" for each server. somecommand
would then be another python script (or whatever) that opens a telnet
connection to that server. See the xterm docs for more info.

Maybe what you really want is to remotely execute reconfiguration
commands, instead of opening all those xterms to use manually. See
rsh, ssh, etc.
Jul 3 '06 #16
In article <11**********************@m79g2000cwm.googlegroups .com>,
"valpa" <va********@gmail.comwrote:
>I don't care about security issue by now :), because every one in my
compony know the username/password.
Then why bother with a password at all?
--
A: Skid-marks in front of the hedgehog.
Q: What's the difference between a dead hedgehog on the road, and a dead
top-poster on the road?
Jul 3 '06 #17
vThanks,

vBut I need to to do complicated job in the xterm consoles for servers.
what does it mean, complicated job? Can you be more specific, please?
vSo I need
vto open many xterm consoles and I just want to save my time from
vtelneting...usr/pwd...

vNetwork Ninja wrote:
>valpa wrote:
I'm a net admin for about 20 unix servers, and I need to frequently
telnet on to them and configure them.
It is a tiring job to open a xterm and telnet, username, password to

Jul 3 '06 #18
telnet server must have a password, right?

Lawrence D'Oliveiro wrote:
In article <11**********************@m79g2000cwm.googlegroups .com>,
"valpa" <va********@gmail.comwrote:
I don't care about security issue by now :), because every one in my
compony know the username/password.

Then why bother with a password at all?
--
A: Skid-marks in front of the hedgehog.
Q: What's the difference between a dead hedgehog on the road, and a dead
top-poster on the road?
Jul 3 '06 #19
Maybe I'm not state what I want clearly.

These Unix boxes are not doing important job like email, web server,
etc.
In our lab, these unix boxes are connected to be a network system to
run our protocols and our job is to test the protocols. they are
physically seperated from lab network and seperate from Internet. So I
do not consider the security issue.

There will be a lot of work to do after I login into these servers. I'm
tired to typing the command "telnet".. and I want to do "telnet"
automatically.

Lawrence D'Oliveiro wrote:
In article <11**********************@m79g2000cwm.googlegroups .com>,
"valpa" <va********@gmail.comwrote:
I don't care about security issue by now :), because every one in my
compony know the username/password.

Then why bother with a password at all?
--
A: Skid-marks in front of the hedgehog.
Q: What's the difference between a dead hedgehog on the road, and a dead
top-poster on the road?
Jul 3 '06 #20
valpa schrieb:
Can I do it automatically by python? After that, there have 20 xterm
consoles opened and telneted to their corresponding servers. Then I
could start to type command in these xterms.
Is there a framework/module to automate ssh-sessions/scp-filetransfers
with python-programming ?

Best regards

Marc schoechlin
Jul 4 '06 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Leonardo Henrique Machado | last post by:
Is is possible to create a link that opens a xterm window? The person clicks on the links and a funcion calls /usr/bin/X11/xterm -e ssh <IP> which gives the person a shell on that IP...
0
by: asdf sdf | last post by:
wondering what python resources might be available for python-based legacy system access, particularly to MVS, DB2 and Adabas. What additional pieces might be needed to implement this access? ...
6
by: Donnal Walter | last post by:
Several months ago I tried using the telnet module (on Windows XP) to communicate with a proprietary host on our network. This was unsuccessful due to problems with "option negotiation", and I gave...
23
by: anton.vredegoor | last post by:
Here's my situation: I'm typing this in a public library on a computer with OS windows 2000 server. I can run Internet explorer, word, excel and powerpoint, that's it. Maybe java, but it seems...
4
by: Dennis | last post by:
Hi, I suppose this post could fall under comp.os.linux/comp.os.unix as well, but I figured since my end goal was control from C++ code I figured this group might be the place to start. As the...
4
by: praba kar | last post by:
Dear All, Normally we can send mail using telnet in linux. In the following way telnet Ipaddress 25 mail from: raj@rajkumar.com 250 o.k(response of from commandline) rcpt to: test@oops.co.in...
1
by: Svenn Are Bjerkem | last post by:
Hi, as a user on a linux system I am member of the groups "users" and "design" with users as my default group. To controll the accessibility of some parts of the file system, creation of files and...
4
by: SPJ | last post by:
Is it possible to run specific commands on cisco router using Python? I have to run command "show access-list" on few hundred cisco routers and get the dump into a file. Please let me know if it is...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.