[execnet-dev] how to remotely open a program on win box?

Mathieu Drapeau matdrapeau at gmail.com
Mon Aug 2 21:40:40 CEST 2010


Hi Charles,
after some modifications to the script it appears that what is causing the
problem is really running the script as a service!
When I commented what you suggested, the server is working correctly, it
doesn't jam at the "channel.receive" call.

I am not familiar enough with Windows to find what could cause this error.
If you have any idea where I could look, please tell me.

Thanks,
Mathieu

2010/7/31 Charles Solar <charlessolar at gmail.com>

> I only vaguely remember trying to use the event manager as a debugging
> tools with little to no success.  I would strongly recommend debugging
> in a console window instead of a service instance.
> Source is a string, but printing it out will not help you very much,
> it just contains all the gateway bootstrapping code.  Actually, I bet
> you are getting that error because the source string is to large.
>
> To remove the windows service part from that file, what you need to do
> is comment out all the __init__ code in the service class, and under
> if __name__ == "-_main__" replace process args with something like
> if __name__ == "__main__":
>     svr=ServiceClass( None )
>     svr.main()
>    while True:
>        time.sleep(0.1)
>
> then you can put print statements where ever you want and they will
> print to the console window you started the daemon in.
>
> On Fri, Jul 30, 2010 at 11:07 AM, Mathieu Drapeau <matdrapeau at gmail.com>
> wrote:
> > Hi Charles,
> > I don't think it is the makegateway call that causes problems, I did try
> > bunch of different configuration without any help...
> > But the "source" variable seems weird. The way I understand it, it should
> be
> > a string and I should be able to output in the logs but everytime I try
> to
> > print its value, I get an error like this:
> >
> > "RegisterEventSource/ReportEvent", the parameter is incorrect
> >
> > Here is how I am trying to output the value of source:
> >
> > try:
> >     servicemanager.LogErrorMsg("source = %s" % source)
> > except Exception as e:
> >     servicemanager.LogErrorMsg("error = %s" % e)
> >
> > Any idea?
> >
> > Thanks,
> > Mathieu
> >
> > 2010/7/29 Charles Solar <charlessolar at gmail.com>
> >>
> >> When I was debugging that script what I did was modify it so it was
> >> not a service, but just a little daemon that ran in a console.  Then I
> >> could put print commands in there and find out what was going on.
> >> Something I think you should try is instead of adding the
> >> "popen//python=", just add the python directory to your computers path
> >> and remove that line.  I dont know, but maybe running makegateway like
> >> that is opening a new python interactively, which would probably break
> >> the popen io connection.
> >> If that is all you changed then that is really all I can guess at what
> >> the problem might be.  If you add some print statements and find out
> >> what paths the service is taking when it fails I might be able to help
> >> some more.
> >>
> >> Charles
> >>
> >> On Thu, Jul 29, 2010 at 6:36 PM, Mathieu Drapeau <matdrapeau at gmail.com>
> >> wrote:
> >> > Yes I am currently using the other script and everything works fine.
> >> > Do you know how I can troubleshoot / debug your script?
> >> >
> >> > Thanks,
> >> > Mathieu
> >> >
> >> > 2010/7/29 Charles Solar <charlessolar at gmail.com>
> >> >>
> >> >> mm, well having a python window pop up is a bit suspicious.  Maybe
> the
> >> >> popen io is not connecting correctly.
> >> >> Maybe before trying the advanced process spawning service I wrote up,
> >> >> try the basic 1 python instance service that is in execnet's script
> >> >> directory.
> >> >>
> >> >> Charles
> >> >>
> >> >>
> >> >> On Thu, Jul 29, 2010 at 4:18 PM, Mathieu Drapeau <
> matdrapeau at gmail.com>
> >> >> wrote:
> >> >> > Hi Charles,
> >> >> >
> >> >> > In the source of your server script, I did change the makegateway
> >> >> > definition
> >> >> > to this:
> >> >> >
> >> >> > gw = execnet.makegateway("popen//pytho=C:\Python26\python.exe")
> >> >> >
> >> >> > When I connect to the server, a python box pop and when I try to
> send
> >> >> > basic
> >> >> > command to the server, I never receive any answers. The client just
> >> >> > wait
> >> >> > for
> >> >> > something.
> >> >> > Here is what I tried:
> >> >> >     ch = gw.remote_exec("import os; channel.send(os.getcwd())")
> >> >> >     ch.receive()
> >> >> >
> >> >> > Do you know what could cause this problem?
> >> >> >
> >> >> > Thanks,
> >> >> > Mathieu
> >> >> >
> >> >> >
> >> >> > 2010/7/29 Mathieu Drapeau <matdrapeau at gmail.com>
> >> >> >>
> >> >> >> Hi Charles,
> >> >> >> I was able to install it finally, I needed to change the name of
> the
> >> >> >> file
> >> >> >> (which was socketserver.py and causes conflict).
> >> >> >>
> >> >> >> My problem now when I am trying to do a remote_exec, I am not able
> >> >> >> to
> >> >> >> debug what's happening in the background. Do you have an idea
> >> >> >> where/how
> >> >> >> I
> >> >> >> can see the trace?
> >> >> >>
> >> >> >> thanks,
> >> >> >> Mathieu
> >> >> >>
> >> >> >>
> >> >> >> 2010/7/29 Charles Solar <charlessolar at gmail.com>
> >> >> >>>
> >> >> >>> well, i would check the process list, see if pythonservice.exe is
> >> >> >>> running.  You may need to run it as admin if you are not.  Open
> >> >> >>> services.msc to make sure the service is actually installed (
> named
> >> >> >>> 'python service' creatively enough).
> >> >> >>> If all that is working, then make sure you are connecting to it
> as
> >> >> >>> a
> >> >> >>> socket gateway, not a ssh gateway.
> >> >> >>>
> >> >> >>> Another thing you may want to check, make sure you have the
> latest
> >> >> >>> version I posted which should have a class def for IOJoiner at
> the
> >> >> >>> top.  That version has a few improvements and should work better
> >> >> >>> than
> >> >> >>> the first one i posted.
> >> >> >>> Also, there is a script in the execnet scripts folder called
> >> >> >>> socketservice.py or something which works similarly and might
> work
> >> >> >>> better for you.
> >> >> >>>
> >> >> >>> Charles
> >> >> >>>
> >> >> >>> On Thu, Jul 29, 2010 at 9:54 AM, Mathieu Drapeau
> >> >> >>> <matdrapeau at gmail.com>
> >> >> >>> wrote:
> >> >> >>> > Charles,
> >> >> >>> > Like you mentionned the problem was with sshd which didn't have
> >> >> >>> > the
> >> >> >>> > option
> >> >> >>> > to "interact with the desktop".
> >> >> >>> > This option could be enabled in the windows services panel.
> >> >> >>> > Unfortunately,
> >> >> >>> > this can only be done in Windows XP pre-SP! Since then
> Microsoft
> >> >> >>> > has
> >> >> >>> > disabled this option for security reasons.
> >> >> >>> >
> >> >> >>> > So, I decided to switch to a socket server. I did see the
> socket
> >> >> >>> > server
> >> >> >>> > script you posted but I am not able to make it work.
> >> >> >>> > I do install and start the server but I am not able to connect
> to
> >> >> >>> > it.
> >> >> >>> > Seems
> >> >> >>> > it is not running because when I try to stop it right after, it
> >> >> >>> > says
> >> >> >>> > the
> >> >> >>> > service has not been started.
> >> >> >>> >
> >> >> >>> > Do you have an updated version of your script? Do you have an
> >> >> >>> > idea
> >> >> >>> > why
> >> >> >>> > the
> >> >> >>> > script seems not to be running?
> >> >> >>> >
> >> >> >>> > thanks,
> >> >> >>> > Mathieu
> >> >> >>> >
> >> >> >>> > 2010/7/27 Charles Solar <charlessolar at gmail.com>
> >> >> >>> >>
> >> >> >>> >> I suspect that cygwin's sshd probably operates in
> >> >> >>> >> non-interactive
> >> >> >>> >> mode.  Check the process list on the computer, does calc.exe
> >> >> >>> >> show
> >> >> >>> >> up?
> >> >> >>> >> If so, it just means that sshd is indeed non-interactive which
> >> >> >>> >> means
> >> >> >>> >> it will not spawn graphical windows for logged in users.
>  There
> >> >> >>> >> is
> >> >> >>> >> probably some way for it to do so, but it would be a cygwin
> >> >> >>> >> thing,
> >> >> >>> >> not
> >> >> >>> >> execnet specificly =/
> >> >> >>> >>
> >> >> >>> >> Charles
> >> >> >>> >>
> >> >> >>> >> On Tue, Jul 27, 2010 at 4:36 PM, Mathieu Drapeau
> >> >> >>> >> <matdrapeau at gmail.com>
> >> >> >>> >> wrote:
> >> >> >>> >> > Hi,
> >> >> >>> >> > I am trying to connect to a windows box and execute a
> program
> >> >> >>> >> > which
> >> >> >>> >> > requires
> >> >> >>> >> > the display using execnet. The windows box has cygwin
> >> >> >>> >> > installed
> >> >> >>> >> > where
> >> >> >>> >> > sshd
> >> >> >>> >> > is running.
> >> >> >>> >> > Here is a small example of what I am trying to achieve.
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> > # remote.py script which should open the windows calculator
> >> >> >>> >> > utility
> >> >> >>> >> > from subprocess import call
> >> >> >>> >> > if __name__ == '__channelexec__':
> >> >> >>> >> >     call(["calc"])
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> > #code to run locally
> >> >> >>> >> > import execnet, remote
> >> >> >>> >> > gw = execnet.makegateway("ssh=%s" % WINBOX_IP)
> >> >> >>> >> > ch = gw.remote_exec (remote)
> >> >> >>> >> > ch.waitclose ()
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> > Looking on the screen of my windows box, I don't see any
> >> >> >>> >> > calculator
> >> >> >>> >> > program!
> >> >> >>> >> > Is it expected?
> >> >> >>> >> >
> >> >> >>> >> > Thanks,
> >> >> >>> >> > Mathieu
> >> >> >>> >> >
> >> >> >>> >> > _______________________________________________
> >> >> >>> >> > execnet-dev mailing list
> >> >> >>> >> > execnet-dev at codespeak.net
> >> >> >>> >> > http://codespeak.net/mailman/listinfo/execnet-dev
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >
> >> >> >>> >
> >> >> >>
> >> >> >
> >> >> >
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/execnet-dev/attachments/20100802/52a453d1/attachment.html>


More information about the execnet-dev mailing list