listing files on remote server

I am writing a script where in i have to log into a remote machine and check for necessary file by typing (ls -ltr *200505) (this gets all 05month of 2008 yr files) and if files are found get them to the local machine. If not found print a message saying no files on local machine.
When i was trying to accomplish this , i was able to log in to the remote server but cannot write ls -ltr command on remote server. When i tried , it says "Remote file local file" i couldnt understand. Please help.

are you using rexec command ?

If the rsh connectivity is there between the machine... then do this way

rsh REMOTE_IP $DIR_NAME/<command>

e.g.
rsh 10.15.1.19 /home/user1/ls

Hope it will work !!!

No
I can connect to the remote machine and can view the files.
But when i tried to get the count of files for a particular month, the command we usually use is `ls -ltr *200805" | wc -1`. This gets the count of files for the 200805(yyyymm). But when i put the same command on remote machine the error out is "ls remotefile localfile". Its asking me to get the count on the local file. But if i do this, i have to come out of the ftp , check the count in local file, and if greater then zero, again login to ftp location. This will be a pain. I want to check the count at FTP location only and if greater than zero get the files onto my local machine.