REXEC - Online Linux Manual PageSection : 3
Updated : 14 February 2017
Source : NFStest 2.1.5
Note : rexec 1.2
NAMEnfstest.rexec - Remote procedure module
DESCRIPTIONProvides a set of tools for executing a wide range commands, statements, expressions or functions on a remote host by running a server process on the remote host serving requests without disconnecting. This allows for a sequence of operations to be done remotely and not losing state. A file could be opened remotely, do some other things and then write to the same opened file without opening the file again. The remote server can be executed as a different user by using the sudo option and sending seteuid. The server can be executed locally as well using fork when running as the same user or using the shell when the sudo option is used. In order to use this module the user id must be able to 'ssh' to the remote host without the need for a password.
CLASSES
class RemoteServerMethods defined here:
---------------------
__del__(self)
Destructor
__init__(self, port, logfile=None)
Remote procedure server
log(self, msg)
Write message to log file
start(self)
class Rexec(baseobj.BaseObj)Rexec object
Rexec() -> New remote procedure object
Arguments:
servername:
Name or IP address of remote server
logfile:
Name of logfile to create on remote server
sudo:
Run remote server as root
Usage:
from nfstest.rexec import Rexec
# Function to be defined at remote host
def add_one(n):
return n + 1
# Function to be defined at remote host
def get_time(delay=0):
time.sleep(delay)
return time.time()
# Create remote procedure object
x = Rexec("192.168.0.85")
# Define function at remote host
x.rcode(add_one)
# Evaluate the expression calling add_one()
out = x.reval("add_one(67)")
# Run the function with the given argument
out = x.run("add_one", 7)
# Run built-in functions
import time
out = x.run(time.time)
# Import libraries and symbols
x.rimport("time", ["sleep"])
x.run("sleep", 2)
# Define function at remote host -- since function uses the
# time module, this module must be first imported
x.rimport("time")
x.rcode(get_time)
# Evaluate the expression calling get_time()
out = x.reval("get_time()")
# Run the function with the given argument
out = x.run("get_time", 10)
# Open file on remote host
fd = x.run(os.open, "/tmp/testfile", os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
count = x.run(os.write, fd, "hello there
")
x.run(os.close, fd)
# Use of positional arguments
out = x.run("get_time", 2)
# Use of named arguments
out = x.run("get_time", delay=2)
# Use of NOWAIT option for long running functions so other things
# can be done while waiting
x.run("get_time", 2, NOWAIT=True)
while True:
# Poll every 0.1 secs to see if function has finished
if x.poll(0.1):
# Get results
out = x.results()
break
# Create remote procedure object as a different user
# First, run the remote server as root
x = Rexec("192.168.0.85", sudo=True)
# Then set the effective user id
x.run(os.seteuid, 1000)
Methods defined here:
---------------------
__del__(self)
Destructor
__init__(self, servername=None, logfile=None, sudo=False, sync_timeout=0.1)
Constructor
Initialize object's private data.
servername:
Host name or IP address of host where remote server will run
[Default: None (run locally)]
logfile:
Pathname of log file to be created on remote host
[Default: None]
sudo:
Run remote procedure server as root
[Default: False]
sync_timeout:
Timeout used for synchronizing the connection stream
[Default: 0.1]
close(self)
Close connection to remote server
poll(self, timeout=0)
Return whether there is any data available to be read
timeout:
Maximum time in seconds to block, if timeout is None then
an infinite timeout is used
rcode(self, code)
Define function on remote server
results(self)
Return pending results
reval(self, expr)
Evaluate expression on remote server
rexec(self, expr)
Execute statement on remote server
rimport(self, module, symbols=[])
Import module on remote server
module:
Module to import in the remote server
symbols:
If given, import only these symbols from the module
run(self, *kwts, **kwds)
Run function on remote server
The first positional argument is the function to be executed.
All other positional arguments and any named arguments are treated
as arguments to the function
wait(self, objlist=None, timeout=0)
Return a list of Rexec objects where data is available to be read
objlist:
List of Rexec objects to poll, if not given use current object
timeout:
Maximum time in seconds to block, if timeout is None then
an infinite timeout is used
SEE ALSObaseobj(3)
BUGSNo known bugs.
AUTHORJorge Mora (mora@netapp.com) 0
Johanes Gumabo
Data Size : 17,559 byte
man-nfstest.rexec.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 172,265
Visitor ID : :
Visitor IP : 3.144.104.118 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.