Connection to another Unix machine

Requirements

I'm running a shell script from one Unix server A which calculates the line count using "wc -l" of a file which resides in another unix server B.

I have tried the ssh also but i'm not very clear about it and its throwing error. The command I'm trying to use is:

ssh user1@serverB /temp/tmpdir/wc -l abc.txt

Please let me know how can i achieve the same using the shell script.

What error is it throwing?

Error is:

ksh: /temp/tmpdir/wc: not found

try...
ssh user1@serverB cat /path/to/abc.txt | wc -l

ssh -l user host "wc -l /path/to/abc.txt" works too

Thanks..

both the above command works ..

but what if i dont want the word count of that file and just want to make a check whether the file is present on the remote unix machine?

how to do that?

In addition to the previos query ... i have tried FTP also.

on 2 machines the connection and the script works fine. But on one machine it gives the following error:

ftp: connect: Connection refused
ftp: connect: Connection refused

What should I do?