Reputation: 6739
I want to use the line below to change a password. When I put actual values instead of variables, the command works perfectly.
echo -e "$sshpass\n$sshpass | (passwd --stdin root)"
$sshpass
is a variable containing a password.
I tried the following to make commands work with no luck:
echo -e "/$sshpass\n/$sshpass | (passwd --stdin root)"
echo -e "$sshpass\n$sshpass | (passwd --stdin root)"
echo -e "'$sshpass'\n/'$sshpass' | (passwd --stdin root)"
How can I make it work?
Upvotes: 2
Views: 235
Reputation: 753870
Use this:
echo -e "$sshpass\n$sshpass" | passwd --stdin root
Upvotes: 1
Reputation: 241888
Do not include the rest of the pipeline in the double quotes. The subshell (parentheses) is not needed.
echo -e "$sshpass\n$sshpass" | passwd --stdin root
Upvotes: 5