How to display files of server2 in server1?

hi,

i have two servers in unix. say server1 and server2. my shell script is running on server1.

In server2, there is a directory (/etc/data/) which contains some text files.

I want to write the list of filenames in server2 in a file and display the file in server1.

In short, i want to display the filenames present in server2 in server1.

i thought i can use FTP like..

ftp server2 <<FTP1
quote USER aaaa
quote PASS bbbb
cd /etc/data
Files=`ls -l | cut -c45-`
FTP1

In the aboce code i tried to populate a variable with the file names which are present in server2, but it doesnt work.

can any1 help doing this? or suggest some other method..

Thanks

you can mount the server2:/etc/data/ on server1 using nfs and then you can possibly list the files exist in the directory on server1.

Thanks for the reply. Can you please give me sample code how to mount? i dnt know these commands. and i need it urgently. so can you please..

on server2:

  1. Install nfs-utils package #yum install nfs*
    2.the /etc/exports file will be available
    3.#vi /etc/exports
    enter following to export the directory.
    /etc/data/ server1(rw,sync,no_root_squash)

Note: you can use the IP address of server1 instead of hostname.
save file
4.restart nfs service and portmap service.
/etc/init.d/nfs restart
/etc/init.d/portmap restart

on Server1:
5.use following command on server1 to verify if the nfs mount point is working.
#showmount -e server2
This will show the /etc/data directory.

  1. create a directory on server1 and mount the server2 directory as below.

Ex. on server1 create a directory /mnt/server2

#mkdir /mnt/server2

  1. mount the server2 directory on server1
    server1#mount -t nfs server2:/etc/data /mnt/server2

now you can list the files in directory /mnt/server2 which are actually exist on server2.

you can permanently mount the mount point using below.

in /etc/fstab add following

server2:/etc/data /mnt/server2 nfs defaults 0 0