parameter-passingcommand-line-argumentssshpass

How do I pass arguments inside a remote command using sshpass and ssh


I am running the following code and unable to pass an argument in the command that I am executing on a remote Netapp cluster. Any insight will help

read -p "echo $'\n'Enter the name for this cluster:" cluster

sshpass -p $pswd ssh $username@$hostname 'aggr show; aggr create -aggregate agg1_'$cluster' -disklist 1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7 -simulate true'


Solution

  • Finally tried below syntax to append the variable into the command that I need to execute..

    sshpass -p $pswd ssh $username@$hostname "aggr show; aggr create -aggregate agg1_"$cluster" -disklist 1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7 -simulate true"