473,394 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.

This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?

Jul 1 '06 #1
13 2356

gavino wrote:
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?


Try pxssh from pexpect. Look at the sample in the page.
http://pexpect.sourceforge.net/pxssh.html
It will allow you to automate ssh interactions.

Jul 1 '06 #2
Does this require a ssh client or server?

I use authpf to open up my PF firewall for internet use. Generally I just
open up putty and make a connection to the FW ( which open the ports) and
minize it till I am done. When I close putty authpf losses the ssh session
heartbeat and will then instruct the FW to close the ports. I would love to
write a simple client to do this form me instead of using putty. Do you
think these mods would work for me on a windows platform?

Thx

"Ravi Teja" <we*********@gmail.com> wrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...

gavino wrote:
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?


Try pxssh from pexpect. Look at the sample in the page.
http://pexpect.sourceforge.net/pxssh.html
It will allow you to automate ssh interactions.

Jul 1 '06 #3
list of servers L.txt
#cat L.txt
config file is /var/bkupexec/agent.cfg need to add "tell epobackup" to
bottom of file
# cat "tell epobackup" >> /var/bkupexec/agent.cfg
agent is /etc/init.d/agent.ini stop (and then start)
# /etc/init.d/agent.init stop
# /etc/init.d/agent.init start
os=redhat ent 4ES
I intend to use root password which is same for all 100 servers.
#now I'm stuck

Ravi Teja wrote:
gavino wrote:
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?


Try pxssh from pexpect. Look at the sample in the page.
http://pexpect.sourceforge.net/pxssh.html
It will allow you to automate ssh interactions.


Jul 1 '06 #4
LittlePython wrote:
Does this require a ssh client or server?

I use authpf to open up my PF firewall for internet use. Generally I just
open up putty and make a connection to the FW ( which open the ports) and
minize it till I am done. When I close putty authpf losses the ssh session
heartbeat and will then instruct the FW to close the ports. I would love to
write a simple client to do this form me instead of using putty. Do you
think these mods would work for me on a windows platform?

Thx
Pexpect needs a POSIX system. However, you can use Cygwin.
From the website, "Pexpect does not currently work on the standard

Windows Python (see the pty requirement); however, it seems to work
fine using Cygwin."

Jul 1 '06 #5
thx,
"Ravi Teja" <we*********@gmail.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
LittlePython wrote:
Does this require a ssh client or server?

I use authpf to open up my PF firewall for internet use. Generally I just open up putty and make a connection to the FW ( which open the ports) and minize it till I am done. When I close putty authpf losses the ssh session heartbeat and will then instruct the FW to close the ports. I would love to write a simple client to do this form me instead of using putty. Do you
think these mods would work for me on a windows platform?

Thx


Pexpect needs a POSIX system. However, you can use Cygwin.
From the website, "Pexpect does not currently work on the standard

Windows Python (see the pty requirement); however, it seems to work
fine using Cygwin."

Jul 1 '06 #6

gavino wrote:
list of servers L.txt
#cat L.txt
config file is /var/bkupexec/agent.cfg need to add "tell epobackup" to
bottom of file
# cat "tell epobackup" >> /var/bkupexec/agent.cfg
agent is /etc/init.d/agent.ini stop (and then start)
# /etc/init.d/agent.init stop
# /etc/init.d/agent.init start
os=redhat ent 4ES
I intend to use root password which is same for all 100 servers.
#now I'm stuck


Read L.txt from (not your shell as you seem to be doing) Python and
connect to each one from pxssh, and send the commands you listed. I am
afraid, you will have to readup and experiment on a smaller scale. The
sample I pointed you to is a rather simple one and you don't seem to
have even tried it.

Jul 1 '06 #7
I would sugest looking at http://pexpect.sourceforge.net/ The Expect
metalanguage was specifically designed for the kind of things you are
trying to do. I used it recently on a project to configure 25
instances of an application, remotly, half over ssh half over telnet.

Jul 1 '06 #8
"gavino" <bo******@yahoo.comwrote in message
news:11*********************@d56g2000cwd.googlegro ups.com...
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?
Could this project help you? http://sourceforge.net/projects/distribulator/

It sounds similar to what you describe.

-- Paul

Jul 1 '06 #9
* gavino (2006-07-01 11:34 +0000)
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?
Tentakel
Jul 2 '06 #10
gavino wrote:
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.
What script would allow this?
I wouldn't use python at all (like swearing on this list???) .... simple
shell-command is more than sufficient.

for server in "server1 server2 server3 .... server100"
do
ssh root@$server "(echo "new line" >config.file; stop-command ;
sleep 5 ; start-command)"
done

I would however have extended the procedure with a few more checks...
Like:
* only add new line to config-file if it isn't present
* only do restart if config-file was modified

Regards,
Jul 2 '06 #11
gThis seems easy but I have been asking tcl and python IRC chat all day
gand no one gave an answer.
gI have 100 servers which need a new backup server added to a text file,
g and then the backup agent restarted.
gIf I have a list of the servers, all with same root password, and the
gconnection is ssh.
gHow do I connect to the server, cat the line to the config file, stop
gadn start the agent, and then do same to next server in list and
giterate through the 100 servers.
gWhat script would allow this?

Maybe webmin could help. http://www.webmin.com/
You can manage cluster of servers at once.

Petr Jakes

Jul 2 '06 #12
Ove Pettersen <ov***********@smartcall.nowrote:
for server in "server1 server2 server3 .... server100"; do
Two comments:

1. Leave out the quotes(!)

2. Either iterate as
for server in $(seq -fserver%g 100); do
or, probably better
for server in $(cat server-list); do
Jul 2 '06 #13
Hehe, yeah, it does feel like swearing =)

That solution works, as long as the network behaves PERFECTLY and
you've allready configured the server to use your SSH key instead of a
password. Expect, by its nature, waits until the right time to say
things

Sample pexpect code:
------------- Code -------------
# assumes hosts is a list of hostnames
for host in hosts:
child = pexpect.spawn("ssh root@%s" % host)
child.expect ('Password:')
child.sendline ("the correct root password")
child.expect ('#') # root prompt
child.sendline("echo 'the new line' >/etc/config.file")
child.expect('#')
child.sendline("/etc/init.d/myservice restart")
child.expect("#")
child.sendline("logout")
-----------------------------

Or if you prefer a stronger split between data and code you can use
this code. If you need even more functionality than that (such as
pausing for a few seconds after a command), you can start using
callable objects instead of tuples of text.

------------- Code ---------------
# commands is a list of (text-to-wait-for, response-to-send) pairs
commands = [ \
("Password:", "the correct root password"), \
("#", "echo 'the new line' >/etc/config.file"), \
("#", "/etc/init.d/myservice restart"), \
("#", "logout") ]

for host in hosts:
child = pexpect.spawn("ssh root@%s" % host)
for cmd in commands:
child.expect(cmd[0])
child.sendline(cmd[1])
-------------------------------------------------

You can also tell pexpect to have a timeout on any expect() call.

Shell has its uses. My personal experiance is shell's use is when you
dont expect the client to have a more powerful language installed, or
when a scripts duties are very limited. If ANYTHING involves a space,
dont bother with shells, handling spaces will take more debugging than
the actual code. For example, your quickly written code wouldn't work
because you have " inside ", when you needed single quotes. And if any
of the commands issued have difficult parameters, properly escaping
shell strings is an utter nightmare. A shell solution may work here,
but if the task gets any more complicated, then a new language is
needed.

I'm a toolkit programmer - I keep as many language as I can in my
toolkit. Pexpect was 100% designed for this specific task, so why not
use it. If I was parsing a text file, 9 times out of 10 I'll pull up
PERL, its ment for it.
Ove Pettersen wrote:
>
I wouldn't use python at all (like swearing on this list???) .... simple
shell-command is more than sufficient.

for server in "server1 server2 server3 .... server100"
do
ssh root@$server "(echo "new line" >config.file; stop-command ;
sleep 5 ; start-command)"
done

I would however have extended the procedure with a few more checks...
Like:
* only add new line to config-file if it isn't present
* only do restart if config-file was modified

Regards,
Jul 3 '06 #14

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

Similar topics

1
by: Ben M. | last post by:
Greetings all, This should be an easy task, and Im sure it is, but as many times as I have tried, I cant seem to get this to work properly. We changed ISPs recently from a shared host to a...
6
by: Charles Morrall | last post by:
I have no experience with DB2 as such, but I've been tasked with configuring backup of a server running DB2 v8 on Windows Server 2003. I do have some experience with backups in general though. The...
3
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2...
6
by: cj | last post by:
I'm tryin to set up a sqlcommand in VB.NET that would issue the command: insert into server1.database.owner.table select * from server2.database.owner.table Since this sqlcommand has it's...
2
by: happyjenny52 | last post by:
Hi, I work as an IT Administrator and part of my job role is to use Enterprise Manager and Query Analyzer to backup the logins and permissions for each database on our SQL Servers. This...
3
by: alwinkotiya | last post by:
Hi all, If I set recovery model SIMPLE then truncation of log files will be automated , but I will lose database changes made since the last backup was taken. Is there any way to automate...
4
by: gavino | last post by:
This seems easy but I have been asking tcl and python IRC chat all day and no one gave an answer. I have 100 servers which need a new backup server added to a text file, and then the backup...
2
by: garther | last post by:
Hi I'm trying to get something like this to work: Application calculates data and stores them in local SQL server. Once a week this data needs to copied to DVD. Then I need second application...
4
by: phirestorm | last post by:
Hopefully someone can help me with an issue i am having. First off let me say that i have little to no experience with MS SQL or SQL in general. We have a Windows 2003 server running MSSQL (i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.