bash - 将脚本运行到远程计算机时出现问题
问题描述
我通过 ssh 将脚本运行到远程机器:
ssh -p$port $user@$ip "bash /dati/bin/add_data.sh $t_ext_aria $t_pannello $t_ext_muro $t_cantina $t_bollitore $t_PT $t_P1 $t_P2 $H_PT $H_P1 $H_P2"
脚本 add_data.sh (在远程机器中)的内容非常不言自明:运行一个 mysql 查询,传递 11 个参数:
query="INSERT INTO temp (t_ext_aria , t_pannello , t_ext_muro , t_cantina , t_bollitore , t_PT , t_P1 , t_P2 , H_PT , H_P1 , H_P2) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,${10},${11})"
echo $query >> debug.log
mysql --user=rf --password=password tana << EOF
$query;
EOF
一切正常,除了它没有在 debug.log 中记录任何内容(我需要记录以调查为什么有时 mysql 查询失败:可能是一些错误的格式数据)
但是如果我登录到远程机器并从那里运行脚本:例如
bash add_data.sh 1 1 1 1 1 1 1 1 1 1 1
它正确写入 debug.log 。
我放了 777 许可以避免任何问题。
我哪里错了?
谢谢的工厂
解决方案
推荐阅读
- ruby-on-rails - Rails 枚举防止 PG 中的破坏操作
- django - 带有多个扩展模板的 django 样式和 allauth
- python - 如何在python中每隔几秒钟在tkinter窗口中更改一行文本
- ionic-framework - 离子:单击“确定”时防止警报自动关闭
- c++ - 如何在 EXECUTE_PROCESS 中使用 FILE(GLOB_RECURSE) 的结果?
- html - 为什么一些 HTML/CSS 设计者在他们的 HTML 中使类名复杂化?
- c# - 如何根据输入参数更改我正在使用的类的命名空间?
- javascript - 添加两个随机数,具有不同的 setTimeout(代码几乎可以工作)
- markdown - 包含括号的 GitHub Markdown 链接
- bootstrap-4 - 如何让 Bootstrap Nav-Pills 选项卡链接和页面链接同时工作