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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sactiw

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


    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_co mmand(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...p20005226.html
    Sent from the Python - python-list mailing list archive at Nabble.com.

Working...