- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: question with remote copy...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 05:59 PM
02-01-2007 05:59 PM
I do have on one machine 20-30 files that need to copy to other machine in certain directory..
Machine A
2003file1
2003file2
2004file34
..
...
to copy from machine A fo machine B I did this:
rcp 2003file1 x1machineB:/path/to/copy/to
and that works for one file..also it works
rcp * x1machineB:/path/to/copy/to
to copy all files..
but I tried something like this:
if file exist on machine B that do not copy file..else if file does not exist on machine B copy if from Machine A to machine B
hmmm I hope I did not confuse U...
Thanks in advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 06:54 PM
02-01-2007 06:54 PM
Re: question with remote copy...
You can use remsh or rexec to execute command from remote shell. To check if file exists and is ordinary file you can use somthing similar to follow:
if [ -f
then
......
......
else
......
......
fi
Unfortunately I can't use remsh and rexec ona my machines to test it.
good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 07:08 PM
02-01-2007 07:08 PM
Re: question with remote copy...
But I need to chack from machine A weather file exist on machine B..
I mean 20 or 30 files..
if [ -e Subs$d ] ; then
rcp 2003file1 x1machineB:/path/to/copy/to
else
echo "test" >/dev/null
fi
Also I would like to note that I tryed this also:
for file in $(< dirlsttemp.dat);
do
...here I did put rsh..
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 07:11 PM
02-01-2007 07:11 PM
Re: question with remote copy...
have you thought about tar ?
tar your directory on Machine A
then transfer the dir.tar file
untar on Machine B
If a file in tarfile already exists on Machine B it will not overwrite, otherwise it will create the file.
This may require a test, as this is from memory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 07:54 PM
02-01-2007 07:54 PM
Re: question with remote copy...
Let assume you want to copy all files from your /dir on local host to /DIR on remote host
host_a is the local host
host-b ise the remote host
on host_a:
for file in `ls /homr/amonamon`
do
rexec host_b -l amonamon -n 'if [ ! -f /DIR/$file ];then
done
rgds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 07:56 PM
02-01-2007 07:56 PM
Re: question with remote copy...
If I transfer all.tar as one file where all files are packed or if I transfer all files as
rsh * ...
I am thinking is it possible not to copy files that are copied for example day before..
one day I copy all files to remote machine..that is OK..
Next day..I want to copy just those that are new..if there are new files..
thanks..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 08:16 PM
02-01-2007 08:16 PM
SolutionHere is a script, it checks also the checksum.
hope it helps.
# cat test_copy.sh
#!/usr/bin/ksh
remote_machine=machineb
remote_path=/path/to/copy
local_path=/source/path
copy_user=root
files=$(ls ${local_path})
for file in ${files} ; do
exists=$(remsh ${remote_machine} ls ${remote_path} | grep -E ^${file}$ | wc -l )
if [ ${exists} -ne 1 ]
then
checksum=$(cksum ${local_path}/${file} | awk '{print $1}')
echo "Copy ${file}"
rcp ${local_path}/${file} ${copy_user}@{remote_machine}:${remote_path}/.
if [ ${checksum} -ne $(remsh ${remote_machine} cksum ${remote_path}/${file} | awk '{print $1}') ]
then
echo "False"
fi
else
echo "${file} exists"
fi
done
Don't forget to edit the .rhosts file for var copy_user.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2007 08:22 PM
02-01-2007 08:22 PM
Re: question with remote copy...
please see:
man rdist
" rdist facilitates the maintaining of identical copies of files over multiple hosts. It preserves the owner, group, mode, and modification time of files if possible and can update programs that are executing."
but if you do want a script solution:
"remsh remote directory exist test"
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=862210
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 01:17 AM
02-02-2007 01:17 AM
Re: question with remote copy...
but what is the meaning of :
grep ^${file}$
:(
thanks..it works..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 01:24 AM
02-02-2007 01:24 AM
Re: question with remote copy...
the ^ means its on the beginning of the filename and the $ at the end of the filename
for additional infos check "man regexp"
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 01:25 AM
02-02-2007 01:25 AM
Re: question with remote copy...
> but what is the meaning of :
grep ^${file}$
The argument passwd to 'grep' is a regular expression. The caret (^) means anchor pattern to match to the beginning of a line. The ${file} variable is expanded by the shell into whatever it represents. The dollar sign anchors the pattern to match to the end of a line.
Hence, the pattern to match must be the whole line to be succesfully matched.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 05:13 PM
02-02-2007 05:13 PM
Re: question with remote copy...
Note there was no reason to use the -E overkill with the grep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2007 07:08 PM
02-04-2007 07:08 PM
Re: question with remote copy...
Cheers,