linux - 使用一个 bash 脚本在 diff 目录中执行多个 bash 脚本

标签 linux bash shell scripting

我有多个 bash 脚本来在多个目录中反弹 Jboss 实例。这些脚本接受参数

开始|停止 |重新加载 |状态 |重启。

 /opt/xyz/x/X_FE.sh 
 /opt/xyz/x/X_BE.sh
 /opt/xyz/y/Y_FE.sh
 /opt/xyz/y/Y_BE.sh
 /opt/xyz/z/Z_BE.sh

我希望有一个 bash 脚本接受相同的参数并执行上面提到的所有 5 个脚本。

/opt/singlescript.sh start ---- must execute all the 5 scripts with start argument.

如有任何帮助,我们将不胜感激。

最佳答案

它看起来像这样。有多种方法可以做到这一点,这只是一种方法

#!/bin/bash
echo "invoking x/X_FE with $1"
sh /opt/xyz/x/X_FE.sh $1

echo "invoking x/X_BE with $1"
sh /opt/xyz/x/X_BE.sh $1

echo "invoking y/Y_FE with $1"
sh /opt/xyz/y/Y_FE.sh $1

echo "invoking x/Y_BE with $1"
sh /opt/xyz/y/Y_BE.sh $1

echo "invoking z/Z_FE with $1"
sh /opt/xyz/z/Z_BE.sh $1

关于linux - 使用一个 bash 脚本在 diff 目录中执行多个 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40221417/

相关文章:

linux - 如何维护旧 Linux 内核的应用程序

c - C 中使用 pipe()、execlp() 和 dup() 的三重管道

linux - 在 bash 中运行具有依赖性的并行函数

shell - Xamarin 表单 : Can Add tabs in Shell App programmatically on the contentpage

css - 如何将所有 CSS 文件更改为 SCSS

shell - sed语法错误

linux - 需要有关 Linux Shell 脚本的帮助以查找字符串模式

python - 初始性能的脚本语言选择

linux - 连接丢失时自动关闭 PuTTY

bash - 如何在 bash 中搜索字符串中的字符?