1

I want to pass the following arguments to the bash script:

ssh -t $slaveAddr "chmod a+rwx newSlaveInstallation.sh; 
echo 'running the installation script....';
./newSlaveInstallation.sh $USERNAME $NEW_REPLICATION_VAL "$slaveList"; 
exit"

username is a username like "user", new replication val is a number, and slavelist is a list of new line separated list of IP addresses like "1.2.3.4 derp\n 1.2.3.5 derpp" However, once I pass these three parameters into ssh, for slaveList, it only takes into consideration the IP address and not the entire string of new line separated values. In other words, if within the script, I echo slaveList, it gives me "1.2.3.4" Is there any special formatting to pass in the entire value of the string? Thanks!

4

1 回答 1

4

您需要转义第一个和最后一个引号内的双引号。否则命令将被截断。

ssh -t "$slaveAddr" "chmod a+rwx newSlaveInstallation.sh; 
echo 'running the installation script....';
./newSlaveInstallation.sh $USERNAME $NEW_REPLICATION_VAL \"$slaveList\"; 
exit"
于 2013-08-23T00:30:18.183 回答