检查ksh中的另一台服务器上是否存在目录

时间:2020-12-05 00:03:34

I am trying to verify if a directory exists prior to moving a file in Korn, using the classic:

我正在尝试使用经典来验证在Korn中移动文件之前是否存在目录:

    if [[ -d ${dir} ]]; then
        scp file
    else
        exit 12
    fi

My Problem:
That the directory is on another server, so whenever I check, the script can't find it and therefore fails and exits every time.
My Question:
Is there a way to do a "-d" across the network, perhaps using sftp/scp-like functionality? The user currently does not have to enter a password and can scp fine, so that is one less issue.

我的问题:该目录位于另一台服务器上,因此每当我检查时,脚本都找不到它,因此每次都会失败并退出。我的问题:有没有办法在网络上做一个“-d”,也许使用类似sftp / scp的功能?用户当前不必输入密码并且可以scp罚款,因此这是一个较少的问题。

1 个解决方案

#1


How about

ssh user@host test -d ${dir}

#1


How about

ssh user@host test -d ${dir}