set variable in heredoc section
#!/bin/shwhile read line; do echo Begin $line ssh $USER@$line << \ENDSSH ls -d foo* | wc -l count=`ls -d foo* | wc -l` echo $countENDSSHdone < $1
The only problem with your script was that when the heredoc token is not quoted, the shell does variable expansion, so $count
was being expanded by your local shell before the remote commands were shipped off...