【问题标题】:Checking if a directory exists on another server in ksh检查目录是否存在于 ksh 中的另一台服务器上
【发布时间】:2009-07-27 20:13:48
【问题描述】:

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

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

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

【问题讨论】:

    标签: networking directory ksh


    【解决方案1】:

    怎么样

    ssh user@host test -d ${dir}
    

    【讨论】:

    • 非常感谢...完美解决,刚刚完成:ssh user@host test -d ${dir} if [[ $? -eq 0 ]];然后等等...
    • if ssh ...; then 应该也可以工作......如果你更喜欢单行。
    猜你喜欢
    • 2015-04-14
    • 2013-01-16
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 2012-03-14
    • 2020-03-22
    • 1970-01-01
    • 2014-12-12
    相关资源
    最近更新 更多