Communication Failures

HI ALL,
I have been trying to install a particular software using remote linux server.
some thing like this:
rsh <host ID> /usr/sbin/swinstall -x autoreboot=true -s /tmp/<software> <Product name>.

The problem is whenever I try to install the product through a shell script the installation fails with the following the error message.

======= 09/25/07 09:31:44 MDT BEGIN swinstall SESSION
(non-interactive) (jobid=lca0226-0180)

   * Session started for user "root@lca0226".
     
   * Beginning Selection

ERROR: RPC exception: "Communications failure (dce / rpc)" 09/25/07
09:32:19 MDT
ERROR: Could not start a management session for "lca0226:/". The
system administrator for host "lca0226" may have disabled the
swagentd daemon or there may be a networking problem affecting
the operation. If the swagentd daemon has been disabled, it
can be enabled by the system administrator on "lca0226" by
setting the "SW_ENABLE_SWAGENTD" entry in
/etc/rc.config.d/swconfig to "1" and executing
"/usr/sbin/swagentd -r".
* Target connection failed for "lca0226:/".
ERROR: More information may be found in the daemon logfile on this
target (default location is lca0226:/var/adm/sw/swagentd.log).
* Selection had errors.

======= 09/25/07 09:32:19 MDT END swinstall SESSION (non-interactive)
(jobid=lca0226-0180)

But the same command goes through if i use it directly at the shell prompt.

Any guesses why am I getting such error??

I would like to add few more details.

The error is not recurrent. Sometimes it goes through. Say it fails 8 out of 10 times.
The issue does seem to be with swagent or /etc/hosts file. cause if that would have been the case, the command should have failed everytime rite.

I am trying to create a script for testing the application and using the script as cron job.

Please let me know if anybody has seen something like this.
Barun