bash - 使用外部实用程序 (plink) 运行 shell 脚本 - 无法提供上下文
问题描述
我在 Unix 环境中有一个 shell 脚本,它本身调用其他脚本(它们称为其他脚本),我想使用任务调度程序从 Windows 调用这些脚本。你可以想象这样的事情:
myMainScript.sh (in /myFolder/myOtherFolder)
在这里面,我打电话如下:
#!/bin/bash
cd /myFolder/myOtherFolder <-- this is to provide the context
cd otherSubFolder <-- entering a subfolder
myOtherScript.sh <-- calling script in subfolder
请注意,这myOtherScript.sh
也会调用同一子文件夹中的其他脚本,这些脚本最终可能会调用其他脚本,我无法修改这些脚本,因为它们是我没有权限的“官方”脚本。
当我从 Shell 控制台运行此脚本时,一切正常。当我从 运行此脚本时plink
,它会在第一个命令上引发错误:
myOtherScript.sh: command not found
因此,我尝试提供绝对路径,而不是调用
myOtherScript.sh
... 我打电话
/myFolder/myOtherFolder/otherSubFolder/myOtherScript.sh
在这种情况下,脚本被找到并运行,但是我对内部调用的脚本有同样的问题myOtherScript.sh
(我没有修改权限)。
我也试过把myMainScript.sh
里面的所有内容pushd + popd
(提供上下文/myFolder/myOtherFolder
),但仍然没有运气。
谁能引导我正确的方向?
Ps 以防万一,这是我调用脚本的方式plink
(调用有效,因为我可以阅读命令提示符的日志,表明它已记录到 Unix 环境):
"R:\tools\plink.exe" user@server-pw myPassword -sh -x "/myFolder/myOtherFolder/myMainScript.sh"
解决方案
推荐阅读
- php - Laravel 如何使用另一台服务器作为文件存储
- javascript - How enable next checkbox if top checkbox is checked
- node.js - 跨项目重用公共项目资源
- css - HTML 而非 CSS 中的背景图像
- android - 名称 app 是 app-debug Android android:debug =true
- reactjs - 创建 React 应用程序卡在 npm 审计和 npm 资金上
- excel - 不断将多个数据添加到我的 excel 数据库中,但仅在同一列中
- json - 如何在飞镖中解析这个 JSON?
- flutter - 颤振酒吧得到问题
- c++ - c ++使用ansi获取终端大小