bash - 尝试执行存储在变量中的命令时 bash 脚本出错
问题描述
我试图scanip.sh
通过在另一个脚本 ( ) 中调用它来在后台 ( )中运行一个 bash 脚本stats.sh
。这是stats.sh
脚本:
#!/bin/bash
ifaces=("eth0" "eth1")
scripts_folder="~/comm"
conf_file="~/comm/conf"
scanip=(nohup "$scripts_folder"/scanip.sh "$conf_file" "${ifaces[0]}" &>/dev/null &)
"${scanip[@]}"
我将scanip
命令(调用scanip.sh
)作为数组存储在一个变量中,并尝试在最后一行执行它。但是每次我尝试运行时,输出都是:
./stats.sh: line 7: syntax error near unexpected token `&>'
./stats.sh: line 7: `scanip=(nohup "$scripts_folder"/scanip.sh "$conf_file" "${ifaces[0]}" &>/dev/null &)'
这里有什么问题?我应该如何构建这个脚本?
解决方案
推荐阅读
- applepay - Apple Pay 支付服务异常商人 ID=1234ABCD 未注册域=xyz.com
- r - 命名矩阵角处的列或行
- python - 如何在 docker 容器(python)中运行 selenium
- java - [新手][Java] 对象不知何故为空
- python - 如何使用 setup.py 安装动态库?
- ruby-on-rails - 如何在 Ruby 中显示计算?
- javascript - 如何在运行时获取当前版本的 NPM 包?
- express - 如何设置我在邮递员中发送的请求标头,但在导航器中?
- r - r shiny - 不能将类型“闭包”强制为“双”类型的向量
- c - 如何在 C 中制作 Siren 噪声 wav 文件?