remote login

Hi

i have recently switched to unix environment,i am trying to make a shell script
which logs on to the remote machines and plays some commands and collects the out put into a file.but i am not able to create any file on remote hosts.see
the sample code .

rsh hostname -l username << ENDTAG
cd /in/service
ls -ltr >> tmp.stats
exit
ENDTAG

all the hosts are connected in LAN .could any body please help me out.
thanks in advance.

Try this:

rsh/remsh hostname -l username "cd /in/service; ls -ltr > tmp.stats"

This will create a file called tmp.stats in the /in/service directory on the remote system.

thanks for the code, but i have too many commands to run through a shell script it takes the hostname and username as arguments from a file on local machine and procedes to create tmp.stats file on that host.

So why not do this: write all the commands that you want to execute into a script. Then execute the following sequence of commands:

rcp script_to_execute remote_host:/tmp/script_to_execute
rsh/remsh remote_host -l username /tmp/script_to_execute
rsh/remsh remote_host -l username rm /tmp/script_to_execute

Your redirection and stuff can all go into the script.

Thanks alot blowtorch
i thought of doing it with style of code i have given as sample but that was failed. i have tried your code thats working .
thanq