Advertisement
Guest User

GarciaPL

a guest
Nov 15th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #!/usr/bin/python
  2. import pexpect
  3. import time
  4. import datetime
  5. import os
  6.  
  7. command = "sshfs -p 22 -o allow_other,uid=0,gid=15000,ro linuxlog@bgk50.bank.com.pl:/opt/webwasher-csm/logs /opt/proxy"
  8. password = "<YOUR_PASSWORD>"
  9. mounted_directory = "/opt/proxy";
  10. expect = "linuxlog@bgk50.bank.com.pl's password:";
  11.  
  12. def check_mounted_point():
  13.     try:
  14.         point = pexpect.spawn(command)
  15.         point.expect(expect)
  16.         time.sleep (0.1)
  17.         point.sendline (password)
  18.         time.sleep (10)
  19.     except Exception, e:
  20.         print str(e)
  21.  
  22. def main ():
  23.     check_mounted_point()
  24.  
  25. if __name__ == '__main__':
  26.     if (os.path.ismount(mounted_directory) == False):
  27.         now = datetime.datetime.now()
  28.         print "Mounted point %s was not detected on %s" % (mounted_directory, now);
  29.         main ()
  30.         print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement