1833563 Members
3167 Online
110061 Solutions
New Discussion

The system process

 
SOLVED
Go to solution
hangyu
Regular Advisor

The system process

I have two hosts ( host A and host B ) , some files are rcp files to each other hosts and then removed after rcp ( both hosts will send files to each others ) , it is run by a crontab job , but I have two concerns
1. how to make sure the file has been rcp to another hosts eg. if the network has problem , then the file will not be rcp to host B to avoid to be removed ;

2. if the other side have the same file name , how to make sure the file will not be overwrite eg. add prefix to the file .

could suggest what is the best method ? thx
2. if the other side have the same file name , how to make sure the file will not be overwrite eg. add prefix to the file .

could suggest what is the best method ? thx
7 REPLIES 7
Rajeev  Shukla
Honored Contributor

Re: The system process

You could possibly do the following things in the script you write to rcp the files accross the other host.
1. look for the return code of rcp, if rcp fails you would have return code set to 1 otherwise 0.
2. Before you do a rcp, do a remsh to list the files on the remote server say file1 is the file you want to copy to hostB then make sure that the file doesnt exist by doing
remsh hostB ls file1
if you see something like file not found then go a head with normal rcp otherwise replace the destination file with someother filename while doing rcp

Cheers
Rajeev
Mahesh Kumar Malik
Honored Contributor

Re: The system process

Hi

Pls check for cron log and syslog files for outcome of cron job and errors if any.

good luck
Mahesh
Vibhor Kumar Agarwal
Esteemed Contributor

Re: The system process

I think Rajeev's suggestion is the better one.

Just use a couple of If - then - else in your script to check the things like return codes and presence/absence of files before doing anything else.
Vibhor Kumar Agarwal
hangyu
Regular Advisor

Re: The system process

all suggestions are useful , if I want to have a script to run it , could provide a help .

the requirement as below,
Host A rcp all the files ( /tmp ) to host B , if the file is successfully rcp to host B , it will move to /tmp/edp , if it is fail to copy ( may be due to the failure of network or the file name is exist at host B ) , then don't move the file ( keep the file to make sure it will be rcp to host B ) , all file rcp to host B add a ".txt" extension ( eg. the original file name is oracl the new file name should be oracl.txt ) , could someone can help ? thx in advance.
hangyu
Regular Advisor

Re: The system process

is it possible to do that , could someone advise ? thx
baiju_3
Esteemed Contributor
Solution

Re: The system process

Jun 29, 2005 06:16:09 GMT N/A: Question Author

Hi ,

Pls use the below script as model , and you can customise to include all your options.


#!/bin/sh

remsh Host-A -n "ls -ld /tmp" >/dev/null 2>&1

if [ $? -ne 0 ]
then
echo "Connection problem to Host- B.Exiting !!"
exit 1
fi

chk=no
chk=`remsh Host-B -n "if [ -f /tmp/file]; then echo "yes";fi`
if [ "$chk" = "no" ]
then
echo "File=file Is not copied to /tmp"
else
remsh Host-B -n "mv /tmp/file /tmp/ebp/file.txt"
echo "File is Moved to /tmp/edp"
fi












Good things Just Got better (Plz,not stolen from advertisement -:) )
hangyu
Regular Advisor

Re: The system process

thx your suggestion,

I have a problem , when run the remsh , it pop the "Permission denied." , I know if I update /etc/hosts.equiv , it can remsh to hosts B , but except this method , is there other method that can also run remsh ? thx