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

发布于 2024-07-29 04:25:43 字数 335 浏览 2 评论 0原文

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

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

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

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

    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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞梦里开花 2024-08-05 04:25:43

怎么样

ssh user@host test -d ${dir}

How about

ssh user@host test -d ${dir}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文