123456789101112131415161718192021222324252627 |
- #!/usr/bin/python3
- from subprocess import check_output
- import argparse
- def fs_connect(letter, user, path, _pswd):
- return check_output('net use {0}: \\\sshfs\\{1}@deeejas.asuscomm.com{3} /user:{1} {2}'.format(letter, user, _pswd, path), shell=True)
- def fs_disconnect(*args):
- for letter in args:
- check_output('net use {0}: /delete'.format(letter), shell=True)
- # return check_output('net use {0}: /delete', shell=True)
- # return check_output('net use R: /delete', shell=True)
- parser = argparse.ArgumentParser(description='connect to ssh filesysytem')
- parser.add_argument('-connect', action='store_const', const=fs_connect, dest='cmd', help='connect to file server')
- parser.add_argument('--l', type=str, help='letter where to mount')
- parser.add_argument('--u', type=str, help='username')
- parser.add_argument('--psw', type=str, help='password for secure connection')
- parser.add_argument('--path', type=str, help='path to files', default='')
- parser.add_argument('-disconnect', action='store_const', const=fs_disconnect, dest='cmd', help='disconnect the file server')
- args = parser.parse_args()
- try:
- args.cmd(args.l, args.u, args.path, args.psw)
- except TypeError:
- args.disc(args.l)
|