remsh doesn't work

Hi,

I need to use remsh inside a ksh script. The script would remsh to another machine (maybe different OS) and then execute commands.

A Simple Script:

#!/usr/bin/ksh

remsh sun7656 -l myuser "cd /user.3/MyFolder; ls -lart"

But this gives me the error:
permission denied

I also tried adding the myuser in .rhosts file, but still then it dosent work. I also added the fully qualified name in .rhosts such as : com.mysite.myuser. Still not working. Any Idea?

Before trying in a script you ought to check on command line, many reasons for remsh to fail...

Can you elaborate some of the reasons?
The command dosent seem to run from command prompt as well.

1) Does the box allow?
Clue: in /etc/inetd.conf:

#finger      stream tcp nowait bin  /usr/lbin/fingerd  fingerd
login        stream tcp nowait root /usr/lbin/rlogind  rlogind
shell        stream tcp nowait root /usr/lbin/remshd   remshd
exec         stream tcp nowait root /usr/lbin/rexecd   rexecd

2) Are all the hosts in /etc/hosts?

etc...
When you try in command line what does the remote say?

remsh sun7656

The .rhosts file goes on the target computer in the target user's home directory. The .rhosts file is giving permission for a the named account on the source computer to access the remote account with commands such as "remsh", "rcp" and "rlogin".
That .rhosts file will contain line(s) of the form:
source_computer_name source_user_name
The source_computer_name should be the name (not an alias) returned by "nslookup source_computer_name" when run on the target computer.
A .rhosts file must be owned by root or the owner of the target account.