ssh -f $user@$machine_name "cd $path; shard_path=`find . -name \"shard0\"`; cd $shard_path; mkdir temp"
The directory structure is $path/node0/shard0
In this script, the var shard_path is null, why? And the directorytemp is constructed in the ~/ but not in the shard0.
Because you’re using double quotes around the command to send to the server, that is being expanded locally. It’s trying to substitute
$pathand$shard_pathbased on their local values, and since$shard_pathisn’t defined locally, it expands to nothing.You can avoid a lot of these quoting issues by using single quotes for the command to be executed on the server. The exact quoting that you need depends on exactly where these variables are defined. But from your comments, it sounds like this is the command that you need: