I am writing a script to transfer some files via sftp. I wanted to make the transfer as a local transfer by setting the directory using sshfs, because it greatly simplifies creating the required directory structure. The problem I am facing is that I am not sure how to deal with a situation where you do not have a network connection. Basically I need a way to determine if the sshfs command worked. Any ideas on how to get a script to execute a bail if the remote directory cannot be installed?
Just check if sshfs0 returns (success):
sshfs
sshfs user@host:dir mountpoint || exit 1
, bash || . , , :
||
if !( sshfs user@host:dir mountpoint ); then echo "Mounting failed!" exit 1 fi
Edit:
, . - Sparr 1
. : 0 . , , 0 true false. , ( ).
, mount sshfs. :
if !( mountpoint -q /my/dir ); then echo "/my/dir is not a mountpoint" else echo "/my/dir is a mountpoint" fi
: -bash: !( mountpoint -q /my/dir ): No such file or directory
-bash: !( mountpoint -q /my/dir ): No such file or directory
:
if (! mountpoint -q /my/dir ); then echo "/my/dir is not a mountpoint" else echo "/my/dir is a mountpoint" fi
Source: https://habr.com/ru/post/1708613/More articles:Using SubSonic in VB.Net Web Application - vb.netHow to uniquely identify a user-defined type in D? - metaprogrammingSQL - determining exact matches across multiple records - sqlC # PropertyGrid Drag and Drop - c #Functional Learning Issues - algorithmusing .htaccess for REST makes 301 redirects - restxVal and ViewModel template - can this be done? - asp.net-mvcUIViews overlay - user-interfaceКак избежать ошибки отступа после изменения настроек табуляции в Vim? - vimHow often is a programming language issue an important issue? - performanceAll Articles