How to get the output of channel.exec_command(cmd) while using paramiko ?

sactiw stiwari at nvidia.com
Wed Oct 15 20:57:41 EDT 2008


Hi Friends,
              I am trying to create a file on remote machine and then
setting its file permissions to remote only thus now this file will act as a
lock  for me and as any body else now can't create same file on that machine
and when my work is over I will reset the file permissions and then delete
the file. Thus in our team we can use this mechanism to acquire and release
lock on a remote machine.

Problem is that I using Python thus to run remote command means I have to
use paramiko module present in site-package.

Now problem which I am facing are:

 - How can I make the channel.exec_command(cmd) to return its exit code.

 - Problem is that when i run the lock acquiring code then even though in
that code after creating the file 
   using touch command it changes the file's permissions to read only but
then also any other person is   
   able to create file with same name on same location running the same lock
acquiring code that I had ran.
   In short for the second person the lock acquiring code should fail ahs he
is using touch command to   
   create a file of same name which already exists with RO file permissions.
So how can I avoid that ?

Thanks in Advance.

-sactiw


-- 
View this message in context: http://www.nabble.com/How-to-get-the-output-of-channel.exec_command%28cmd%29-while-using-paramiko---tp20005226p20005226.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list