Bash 将脚本运行到远程计算机时出现问题
我通过ssh向远程计算机运行脚本:Bash 将脚本运行到远程计算机时出现问题,bash,ssh,Bash,Ssh,我通过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(在远程机器中)的内容非常简单:运行一个传递11个参数的mysql查询: query="INSERT INTO
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(在远程机器中)的内容非常简单:运行一个传递11个参数的mysql查询:
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
我把许可证放在777上以避免任何问题
我错在哪里
thank's fab从远程主机显示
ls-al/dati/bin/add_data.sh
。另外,echo$user
来自本地主机。当您通过ssh运行它时,您的脚本将debug.log写入$user的主目录,而不是/dati/bin/。谢谢@cyrus,这就解决了我的问题(我觉得有点愚蠢!)
bash add_data.sh 1 1 1 1 1 1 1 1 1 1 1