参数未正确传递给远程bash脚本

时间:2014-05-10 09:55:42

标签: bash shell

所以我有这个在rhel 5.8上运行的脚本,它的作用是它读取两个参数,应该是yyyy-mm-dd格式的日期,并在远程服务器sunOS 5.10上触发脚本。我正在使用的shell是/ bin / bash

代码中未按预期工作的部分如下:

...
CC="IE"
read -p "Please provide start date (format yyyy-mm-dd): " STARTDATE
read -p "Please provide end date (format yyyy-mm-dd): " ENDDATE
echo ""
echo "Start Date provided :" $STARTDATE
echo "End date provided :" $ENDDATE
echo ""

echo "Executing query on the remote side, please wait..."
ssh -t user@rem_host '/tmp/rem_script.sh '${CC}' '${STARTDATE}' '${ENDDATE}' ' >/dev/null 2>&1

在本地主机上设置-x时我得到的是以下

+ read -p 'Please provide start date (format yyyy-mm-dd): ' STARTDATE
Please provide start date (format yyyy-mm-dd): 2014-05-08
+ read -p 'Please provide end date (format yyyy-mm-dd): ' ENDDATE
Please provide end date (format yyyy-mm-dd): 2014-05-09
+ echo ''

+ echo 'Start Date provided :' 2014-05-08
Start Date provided : 2014-05-08
+ echo 'End date provided :' 2014-05-09
End date provided : 2014-05-09
+ echo ''

+ echo 'Executing query on the remote side, please wait...'
Executing query on the remote side, please wait...
+ ssh -t user@rem_host '/tmp/rem_script.sh IE 2014-05-08 2014-05-09 '

但是我在远程端看到的内容如下:

user   730   688   0 10:30:31 pts/2       0:00 bash -c /tmp/rem_script.sh IE 2014-05-08 2014-05

有人可以告诉我为什么最后一个日期被砍掉了吗?我怎么能纠正这个?

提前致谢...

0 个答案:

没有答案