Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97264 > unrolled thread

reg multiple login python

Started byharirammanohar159@gmail.com
First post2015-10-01 00:04 -0700
Last post2015-10-09 02:07 -0700
Articles 19 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  reg multiple login python harirammanohar159@gmail.com - 2015-10-01 00:04 -0700
    Re: reg multiple login python Laura Creighton <lac@openend.se> - 2015-10-01 09:17 +0200
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-01 01:25 -0700
      Re: reg multiple login python Laura Creighton <lac@openend.se> - 2015-10-01 11:10 +0200
      Re: reg multiple login python Michael Ströder <michael@stroeder.com> - 2015-10-01 11:17 +0200
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-01 03:07 -0700
      Re: reg multiple login python Laura Creighton <lac@openend.se> - 2015-10-01 14:26 +0200
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-01 03:09 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-04 21:01 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-04 21:06 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-05 03:13 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-05 20:22 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-06 02:09 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-06 20:47 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-07 02:24 -0700
      Re: reg multiple login python Emile van Sebille <emile@fenx.com> - 2015-10-07 09:58 -0700
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-08 03:03 -0700
      Re: reg multiple login python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-10-08 08:42 -0400
    Re: reg multiple login python harirammanohar159@gmail.com - 2015-10-09 02:07 -0700

#97264 — reg multiple login python

Fromharirammanohar159@gmail.com
Date2015-10-01 00:04 -0700
Subjectreg multiple login python
Message-ID<2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com>
Hi All,

Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..

Thanks in advance.

[toc] | [next] | [standalone]


#97267

FromLaura Creighton <lac@openend.se>
Date2015-10-01 09:17 +0200
Message-ID<mailman.283.1443683885.28679.python-list@python.org>
In reply to#97264
In a message of Thu, 01 Oct 2015 00:04:16 -0700, harirammanohar159@gmail.com wr
ites:
>Hi All,
>
>Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
>
>Thanks in advance.
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I am not sure that what you said 'do at once' is what you meant.  Actually
making sure that 2 things happen at the same time on different machines
is a rather hard problem.

But you probably don't care.  'Do this thing all these places, asap'
and 'Do this thing, sometime just after 03:00' is what we most of
the time want, and the best you are going to get with your for loop.

How much 'at once' do you need?

Note, if your real problem is 'I have a lot of machines to admininster,
and I need to push changes to all of them, and sometimes some of them
are down, and keeping track of which ones still need the update vs
which ones already have it is a real pain', you may find that
admin tools such as fabric
http://www.fabfile.org/

make your life easier.

Laura

[toc] | [prev] | [next] | [standalone]


#97271

Fromharirammanohar159@gmail.com
Date2015-10-01 01:25 -0700
Message-ID<6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi Laura,

I have checked fabric tutorial and examples, it didn't sound that using fab we can do/push the thing at same time in all servers.
Are you saying that using fab we can login to all servers at same time and do the activity and come out... if so, can you just give me some example..

meanwhile i will try getting fab with py3.3 to machine...

[toc] | [prev] | [next] | [standalone]


#97275

FromLaura Creighton <lac@openend.se>
Date2015-10-01 11:10 +0200
Message-ID<mailman.289.1443690630.28679.python-list@python.org>
In reply to#97271
In a message of Thu, 01 Oct 2015 01:25:47 -0700, harirammanohar159@gmail.com wr
ites:
>On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>> 
>> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
>> 
>> Thanks in advance.
>
>Hi Laura,
>
>I have checked fabric tutorial and examples, it didn't sound that using fab we can do/push the thing at same time in all servers.
>Are you saying that using fab we can login to all servers at same time and do the activity and come out... if so, can you just give me some example..
>
>meanwhile i will try getting fab with py3.3 to machine...
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I still don't know what you mean by 'at the same time'.

But see:
http://www.pythonforbeginners.com/systems-programming/how-to-use-fabric-in-a-development-environment/

change env.hosts to be a list of all the places that you want the things
you put in your fabfile.py to run.

I don't know if this is going to help you, or be any better than just
using a loop.  It depends on what your problem is.  Fabric is designed
to solve a certain set of problems, but I don't know if they are
the sort you have.

Laura

[toc] | [prev] | [next] | [standalone]


#97276

FromMichael Ströder <michael@stroeder.com>
Date2015-10-01 11:17 +0200
Message-ID<muitj1$bnm$1@dont-email.me>
In reply to#97271
harirammanohar159@gmail.com wrote:
> I have checked fabric tutorial and examples, it didn't sound that using fab
> we can do/push the thing at same time in all servers.

What does that mean?

Since the posting's subject contains "login" are you trying to minimize the
number of authentications needed? I had this discussion in project using OTP.

Ciao, Michael.

[toc] | [prev] | [next] | [standalone]


#97277

Fromharirammanohar159@gmail.com
Date2015-10-01 03:07 -0700
Message-ID<a1b0c609-e1ae-4c6c-9ab6-2826fd7b5e8b@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi Laura,

at the same time means...
i have an activity say on two servers serverA and serverB, my aim is to do the activity using script by logging in to both servers serverA and serverB at the same time and not one by one. hope this time i am able to convey :)

in earlier post the way you suggested will work only as one by one..

Thanks.

[toc] | [prev] | [next] | [standalone]


#97279

FromLaura Creighton <lac@openend.se>
Date2015-10-01 14:26 +0200
Message-ID<mailman.290.1443702414.28679.python-list@python.org>
In reply to#97277
In a message of Thu, 01 Oct 2015 03:07:14 -0700, harirammanohar159@gmail.com wr
ites:
>On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>> 
>> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
>> 
>> Thanks in advance.
>
>Hi Laura,
>
>at the same time means...
>i have an activity say on two servers serverA and serverB, my aim is to do the activity using script by logging in to both servers serverA and serverB at the same time and not one by one. hope this time i am able to convey :)
>
>in earlier post the way you suggested will work only as one by one..
>
>Thanks.

I am still not understanding.

Is your problem that you don't want to wait for the script to be done
on machine A before you go to machine B?

fork a separate process for each machine.

You could even do this in, for instance, a bash shell.
Given a script called myscript.py that takes a machine name as an argument.

for machine in `cat list_of_machines`
        do
	python --machine $machine myscript.py &
	done
	
if you need to do this inside python see
os.fork https://docs.python.org/3.4/library/os.html
and make sure you read about the problems with ssl if
you care.  https://docs.python.org/3.4/library/ssl.html#module-ssl

Most people don't need any more 'at the same time' than this.
Do you?

Laura

[toc] | [prev] | [next] | [standalone]


#97278

Fromharirammanohar159@gmail.com
Date2015-10-01 03:09 -0700
Message-ID<2ff0c2aa-910f-40a5-8f98-525f27905cf8@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi Michael,

please see earlier post to know the exact requirement :) and suggest if you have any solutions... :)

Thanks.

[toc] | [prev] | [next] | [standalone]


#97397

Fromharirammanohar159@gmail.com
Date2015-10-04 21:01 -0700
Message-ID<3a9b7eee-f02e-4dd5-a1ec-074c0fd913f7@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi Paul,

subprocess is used to spawn a new process with in the machine.. my requirement is completely different...

[toc] | [prev] | [next] | [standalone]


#97398

Fromharirammanohar159@gmail.com
Date2015-10-04 21:06 -0700
Message-ID<27c50868-37f7-44f9-b81e-ecf85bcdd5b6@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi Laura,

yes this is what i require and i don't need more than this.
how can i fork a pxssh session ?
can i do like this ?
os.fork(pxssh.pxssh()), but how can i capture the session variable ?? whereas fork returns child id and pid..

Thanks...

[toc] | [prev] | [next] | [standalone]


#97404

Fromharirammanohar159@gmail.com
Date2015-10-05 03:13 -0700
Message-ID<d488f37e-f6df-4597-9019-7996fd21569d@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi All,

I am able to achieve it using multiprocessing package...

Thanks.

[toc] | [prev] | [next] | [standalone]


#97429

Fromharirammanohar159@gmail.com
Date2015-10-05 20:22 -0700
Message-ID<25fb0dc7-8c94-451e-ba3b-dce17bfde6b3@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi,

issue in implementing multiprocessing with pxssh, its working fine with normal operations but with pxssh its throwing error as below:
=========
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "./rmcomments.py", line 12, in xcute
    s = pxssh.pxssh()
  File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/pxssh.py", line 91, in __init__
    spawn.__init__(self, None, timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env)
  File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 493, in __init__
    fd = sys.__stdin__.fileno()
ValueError: I/O operation on closed file
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./rmcomments.py", line 23, in <module>
    output = p.map(xcute, [(srvrs) for srvrs in serverslist])
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 599, in get
    raise self._value
ValueError: I/O operation on closed file
======

Below is the code:
------------------------
serverslist = ['server1','server2']
username = 'user1'
password = 'password1'

def xcute(srvrs):
        s = pxssh.pxssh()
        s.login (srvrs, username, password)
        ---do stuff---
        s.sendline('logout')

np = len(serverslist)
p = multiprocessing.Pool(np)
output = p.map(xcute, [(srvrs) for srvrs in serverslist])


can any one help me out!!!!!
Thanks

[toc] | [prev] | [next] | [standalone]


#97434

Fromharirammanohar159@gmail.com
Date2015-10-06 02:09 -0700
Message-ID<2e9d10ba-57cf-4c10-bd02-91ca010c3941@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi,

Anyone suggest...

[toc] | [prev] | [next] | [standalone]


#97467

Fromharirammanohar159@gmail.com
Date2015-10-06 20:47 -0700
Message-ID<f7a4ff72-6b7b-4878-abb9-89a58822b418@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

please respond...actually i am in need of this multiprocessing..

[toc] | [prev] | [next] | [standalone]


#97474

Fromharirammanohar159@gmail.com
Date2015-10-07 02:24 -0700
Message-ID<202cb5a5-0915-4170-a938-bded0c4a7b4a@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

how to handle this ? any one pls help...

[toc] | [prev] | [next] | [standalone]


#97485

FromEmile van Sebille <emile@fenx.com>
Date2015-10-07 09:58 -0700
Message-ID<mailman.456.1444237139.28679.python-list@python.org>
In reply to#97474
On 10/7/2015 2:24 AM, harirammanohar159@gmail.com wrote:
> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>>
>> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
>>
>> Thanks in advance.
>
> how to handle this ? any one pls help...
>

the best you're likely to do to get them running near simultaneously is 
to launch a detached process for each request.  you could adapt your 
current for loop to do so.

emile

[toc] | [prev] | [next] | [standalone]


#97498

Fromharirammanohar159@gmail.com
Date2015-10-08 03:03 -0700
Message-ID<9cd3423a-75c3-4b94-9bc8-cd48e2da4140@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

if its a command i can launch a detached process for each request, its a session..

[toc] | [prev] | [next] | [standalone]


#97501

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-10-08 08:42 -0400
Message-ID<mailman.469.1444308144.28679.python-list@python.org>
In reply to#97498
On Thu, 8 Oct 2015 03:03:17 -0700 (PDT), harirammanohar159@gmail.com
declaimed the following:

>On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>> 
>> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
>> 
>> Thanks in advance.
>
>if its a command i can launch a detached process for each request, its a session..

	You've been posting these (mostly) one-line statements daily for nearly
a week now... Maybe if you actually show us what you've got working we can
extrapolate some solution -- since what you've told us is still too vague
to know what the real requirements are.

	You have been working on this and not waiting for a completed program
to be provided to you, right?

	1) the only way you are going to get "at once" is by having one
process/thread for each server, with all processes waiting for the system
clock to reach some value (and even then, you are going to be affected by
Ethernet congestion and number of cores that can run the processes -- if
you have more servers to contact than active cores you will have to suffer
process swapping by the OS)

	2) have you managed to script the interaction with a single server yet?
That's the first thing you need, before worrying about parallelizing the
action over multiple server connections.

	3) since this sounds like something that will be I/O bound (waiting for
server responses) you could probably get away with using Python threads
instead of independent processes. However, how many servers are we talking
here? Creating 50-100 threads on a decent machine may not be a problem, but
creating 1000 could start impacting memory and cause page file thrashing --
you might have to partition the job to use a pool of threads.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#97532

Fromharirammanohar159@gmail.com
Date2015-10-09 02:07 -0700
Message-ID<51649ddc-6803-4498-a4d6-a096f30ee902@googlegroups.com>
In reply to#97264
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

any way is there ???

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web