[execnet-dev] Executing Interactively on remote machines

arun kali raja arunsep886 at gmail.com
Thu Mar 8 07:26:36 EST 2018


Hi Holger,

Sorry, overlooked the "Working asynchronously/event-based with channels"
section in the document at first glance...

I think that perfectly solves my problem..

*In [1]: import  execnet*

*In [2]: gw =
execnet.makegateway('ssh=wtllab-spirentdev-1.phaedrus.sandvine.com
<http://wtllab-spirentdev-1.phaedrus.sandvine.com>')*

*In [3]: ch = gw.remote_exec("""*

*for item in channel:*
*    channel.send(eval(item))*
*""")*
*In [4]: ch.send('os.chdir("/home/dir1")')*

*In [5]: ch.receive()*

*In [6]: ch.send('os.getcwd()')*

*In [7]: ch.send('os.chdir("/home/dir2")')*

*In [8]: ch.receive()*

*In [9]: ch.send('os.getcwd()')*

*In [10]: ch.close()*

Thanks a lot :)

Regards
Arun Kaliraja.B







On 8 March 2018 at 17:19, holger krekel <holger at merlinux.eu> wrote:

> Hi Arun,
>
> did you look through the examples here:
>
> http://execnet.readthedocs.io/en/latest/examples.html
>
> ?  I guess if you look through them you'll get an idea
> of how to use execnet for your purposes.
>
> holger
>
> > Hi,
> >
> > I bumped upon execnet when i was trying to use pytest-xdist library and
> was
> > looking if it can used for one of my use case.
> >
> > In my usecase i have some package installed in a remote machine.. I need
> to
> > run a python session on these remote machines, import the package, create
> > object,etc..
> >
> > I was thinking if execnet can solve this problem..
> >
> > I saw that the "remote_exec" method that creates the channel needs the
> > source code that has to be executed . So i have to construct a string
> with
> > the series of command and then give it to remote_exec. Is there a way  to
> > achieve a interactive session using the execnet library? ie., send a
> > command recieve the response given by the command and then send the next
> > command..   (when i first saw execnet usage i thought its like opening a
> > python shell on a remote machine and sending commands to it
> > interactively.).
> >
> > Regards
> > Arun Kaliraja.B
>
> > _______________________________________________
> > execnet-dev mailing list
> > execnet-dev at python.org
> > https://mail.python.org/mailman/listinfo/execnet-dev
>
>


-- 
அன்புடன்,
பா. அருண் காளி ராசா
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/execnet-dev/attachments/20180308/b0bfcc93/attachment.html>


More information about the execnet-dev mailing list