Reputation: 47196
I want to mount a remote directory using sshfs. sshfs working fine from terminal. But how to invoke it from within python script?
I tried something like this - but didn't work at all.
import os
cmd = "/usr/bin/sshfs [email protected]:/home/giis /mnt"
os.system(cmd)
Upvotes: 2
Views: 2780
Reputation: 383
import subprocess
mount_command = f'sshfs {host_username}@{host_ip}:{host_data_directory} {local_data_directory}'
subprocess.call(mount_command, shell=True)
# Do your stuff with mounted folder
unmount_command = f'fusermount -u {local_data_directory}'
subprocess.call(unmount_command, shell=True)
Upvotes: 0
Reputation: 342263
first, you should make sure your sshfs command works fine using the shell. Then, go to here to see many examples of using subprocess module of Python to call your sshfs commmand
Upvotes: 3