Solved

Calling program on remote machine

Posted on 2004-10-25
214 Views
Last Modified: 2010-04-16
Hi
How do I call a program over vpn?  The program produces a text fiile that I then download.
0
Question by:gregbinns
    8 Comments
     
    LVL 9

    Expert Comment

    by:rjkimble
    Is this a Python question?
    0
     

    Author Comment

    by:gregbinns
    Yes
    I want to call a python program from a python program.
    Import is difficult because it is on a remote box.
    Thanks
    Greg
    0
     
    LVL 9

    Expert Comment

    by:rjkimble
    If you can see the remote directories as regular directories, you can add things to sys.path and then use import:

    import sys
    sys.path.insert( 0, remote_dir )
    import your_module # where your_module is in remote_dir

    Does that help?
    0
     

    Author Comment

    by:gregbinns
    Thanks
    Could help but what I was really looking for was something like the VB Call(C:\myprog.exe) function.
    Any clues
    Regards
    Greg
    0
     
    LVL 9

    Expert Comment

    by:rjkimble
    The various popen methods from the os and popen2 modules should do what you want. I'm not really familiar with VB, so I don't know what features Call() provides. popen, popen2, popen3, and popen4 all execute a method in a child process and provide access to stdin, stdout, and stderr of the child process. Is that what you're looking for?
    0
     
    LVL 3

    Expert Comment

    by:hweber
    Do I understand you right that you want the called program to execute on the remote machine, not on the machine the calling program is on? If the called programm doesn't provide some kind of rpc calling mechanism, you would need some way to connect to the remote machine that allows you to execute commands there. One of the simplest ways would be telnet if the remote machine offers this.

    For this you could use the telnet library which is part of the Python standard library. Connect to the remote machine, wait until it requests your username and password, answer those queries and then call the program you want to run. Wait until it finishes running, then download the result file.
    0
     
    LVL 3

    Expert Comment

    by:nochkin
    If you can access your remote box over tcp network then I would suggest to use Pyro (Python Remote Object).
    That will let you to access Python classes remotely from your local python script and get your data directly without having downloading it, synchronizing and playing other games to get your file complete etc.
    http://pyro.sourceforge.net/

    There are some other projects like this you might want to look into:
    http://www.fnorb.org/
    0
     
    LVL 3

    Accepted Solution

    by:
    If you want just to execute some other program then you can use os module:

    import os
    os.system('myscript.py')
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
    A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now