issue on ssh command in ksh shell

Hi guru,

I'm making crazy cause an issue on a ksh shell I made.

In this shell I want to execute unix command on a remote machine using an ssh connection like ssh user@host 'command'.....
The command is very simply, is an ls on a remote directory but it give me an unexpected result.

The command is built using a variable:
ssh user@host 'ls ${var}' where var is a concatenation of others variables. Whith this command I want to retrieve a specific file with a specific format like 20120917_filename.csv.gz
So the first variable contain the path in which I looking for the file, the second contains the date and the third contain the extension (.csv.gz).
Because the filename varying I must use the * in the concatenation.
The variable var=${varpath}${vardate}*${varext}
varpath=/oracle/admin/files/
vardate='date "+%Y%m%d"'
varext=.cvs.gz
The issue is related the variable because if I write:
ssh user@host 'ls ${var}'
it return all the file in the dir even if it executes only the ls, meanwhile if I write
ssh user@host 'ls /oracle/admin/files/'date "+%Y%m%d"'
*.csv.gz'
it works correctly.
I don't know why it gave me different result, peraphs is the * that cause the unexpected result but I spend all the day looking for a solution but without result.
Please give me your opinion and contact me if you needed more explanation.
Thanks a lot to all.

 
var="${varpath}${vardate}_*${varext}"

ssh user@host 'ls "$var"'
ssh user@host 'ls "$var"'

Hi, it seems didn't work.

Then ls command is executed correctly only if the path or the filename is hard coding in shell.
If I use variables the result is wrong.

:wall:

I did not red the whole thing, just a quick tip :

 ssh user@host "ls $var"

The way you wrote the code I don;t think the substitution of $var can be done

Yeeeeesss!!!!!!!!!!

Perfect now it works.
Great, now I can test my shell!

Thanks, thanks, thanks to all for the support.