Operating System - HP-UX
1836599 Members
2392 Online
110102 Solutions
New Discussion

find files on remote server

 
SOLVED
Go to solution
Youlette Etienne_2
Regular Advisor

find files on remote server

Hello everyone,

Is it possible to search for files remotely on HPUX 11.0 servers? I am currently writing a version control menu that will automatically move files from a development server, to a production server.

What I want to do is write a script to prompt a user for a filename on the production server, remotely search the development server for the file, and then ftp the file to the production server.

If there is no remote search command, I have a few ideas on how to get around this, though additional ideas would be more than welcome.

Thanks

Youlette
If at first you don't succeed, change the rules!
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: find files on remote server

There is no remote search command that I know of. The only thing I can think of to do is something like:

file_exists = `remsh remote_sys 'find /dir/to/look/in -name file_to_find | wc -l'`

if ( $file_exists > 0 )
then
the file exists on remote system - do appropriate action
else
the file doesn't exist on remote system - do appropriate action
fi
A. Clay Stephenson
Acclaimed Contributor

Re: find files on remote server

Hi,

I would do it using a combination of remsh, find, rcp, e.g.

REMHOST=bugs
echo "Enter desired file: \c"
read F
TFILE=/tmp/xx${$}

remsh ${REMHOST} find / -name "${F}" > $TFILE
if [ -s ${TFILE} ]
then
while read X
do
rcp -p ${REMHOST}:${X} ${X}
done
fi
rm -f $TFILE

This should be a good starting point. rcp is easier to use in scripts than ftp.

man remsh,rcp,find for details.

Regards, Clay
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: find files on remote server

Ooops,

That should be:
cat ${TFILE} | while read X
do
.....
done

Sorry about that, Clay
If it ain't broke, I can fix that.
Youlette Etienne_2
Regular Advisor

Re: find files on remote server

Wow, I really didn't expect such quick responses, less than 10 minutes!

I was thinking along the same lines as Patrick and Clay, though I have not begun scripting yet. These will work very nicely.

Thanks

Youlette
If at first you don't succeed, change the rules!
Celso Medina Kern
Trusted Contributor

Re: find files on remote server

Hi,

Using remsh presumes you?ve already configured equivalent hosts. You can also use:
rexec host [ -l login ] [ -n ] command
instead of:
remsh host [-l username] [-n] command
rexec prompts for a password before executing the command instead of using hosts.equiv for authentication.

Regards.

God bless pessimists, they did the backup!