Note - I posted a similar question yesterday and got a bit further thanks to @cas but am still having problems. I've refined the question so have re-asked it.
I'm passing script text to an ssh command (see below). Inside the script text there are variables that should be expanded. $1 and $2 and $logfilepattern seem to expand fine in the script string. However, $f does not. I've tried every combination of double quotes and single quotes and escapes I can think of but still can't get this to work. Any help appreciated.
Thanks, Max
#!/bin/bash
logfilepattern="drupal-watchdog.log-201510*.gz"
function getlogcounts {
echo in getlogcounts
echo arg1: "$1"
echo arg2: "$2"
ssh $1 "cd "$2"; pwd; echo "$logfilepattern" ; for f in "$logfilepattern"; do echo "$f"; done"
}
server="[email protected] "
logdir="/var/log/mylogs"
getlogcounts $server $logdir
\$f.for f in "$logfilepattern"; do echo "\$f"; donecan be replace byls "$logfilepattern"