I need to run a monkeyrunner script in a remote machine. I'm using python to to automate it and RPyC so that I could connect to other machines, everything is running in CentOS.
written below is the command that I used:
import rpyc
import subprocess
conn = rpyc.classic.connect("192.XXX.XXX.XXX",XXXXX)
conn.execute ("print 'Hello'")
subprocess.Popen("/opt/android-sdk/tools/monkeyrunner -v ALL
/opt/android-sdk/tools/MYSCRIPT.py", shell=True)
and this is the result:
can't open specified script file
Usage : monkeyrunner [option] script_file
-s MonkeyServer IP Address
-p MonkeyServer TCP Port
-v MonkeyServer Logging level
And then I realized that if you use the command below, it is running the command in your machine. (example: the command inside the Popen is "ls" the result that it will give you is the list of files and directories in the current directory of the LOCALHOST) hence, the command is wrong.
subprocess.Popen("/opt/android-sdk/tools/monkeyrunner -v ALL
/opt/android-sdk/tools/MYSCRIPT.py", shell=True)
and so I replaced the code with this
conn.modules.subprocess.Popen("/opt/android-sdk/tools/monkeyrunner -v ALL
/opt/android-sdk/tools/MYSCRIPT.py", shell=True)
And give me this error message
======= Remote traceback ======= Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/rpyc-3.2.2-py2.4.egg/rpyc/core/protocol.py", line 300, in _dispatch_request res = self._HANDLERS[handler](self, *args) File "/usr/lib/python2.4/site-packages/rpyc-3.2.2-py2.4.egg/rpyc/core/protocol.py", line 532, in _handle_call return self._local_objects[oid](*args, **dict(kwargs)) File "/usr/lib/python2.4/subprocess.py", line 542, in init errread, errwrite) File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
======= Local exception ======== Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/site-packages/rpyc-3.2.2-py2.4.egg/rpyc/core/netref.py", line 196, in call return syncreq(_self, consts.HANDLE_CALL, args, kwargs) File "/usr/lib/python2.4/site-packages/rpyc-3.2.2-py2.4.egg/rpyc/core/netref.py", line 71, in syncreq return conn.sync_request(handler, oid, *args) File "/usr/lib/python2.4/site-packages/rpyc-3.2.2-py2.4.egg/rpyc/core/protocol.py", line 438, in sync_request raise obj OSError: [Errno 2] No such file or directory
I am thinking that it cannot run the file because I don't have administrator access (since I didn't supply the username and password of the remote machine)?
Help!