Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 将脚本运行到远程计算机时出现问题_Bash_Ssh - Fatal编程技术网

Bash 将脚本运行到远程计算机时出现问题

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向远程计算机运行脚本:

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