1752793 Members
6078 Online
108789 Solutions
New Discussion

Re: script regarding ssh

 
rahul_rtns
Frequent Advisor

Re: script regarding ssh

I tried
>> echo hello | mailx -s "test mail" rahul_rtns@domain.com

In the mail.log it is giving log as :
Dec 20 00:58:01 houspiqa1 sm-mta[1945]: pBJ9FMjf003896: to=rahul_rtns@domain.com, ctladdr=rtns (116/20), delay=21:42:39, xdelay=00:00:00, mailer=relay, pri=4080152, relay=barbbh1.bwes.net., dsn=4.0.0, stat=Deferred: Connection timed out with barbbh1.bwes.net.
Dennis Handly
Acclaimed Contributor

Re: script regarding ssh

>the mail.log it is giving log as:

>stat=Deferred: Connection timed out with barbbh1.bwes.net.

 

Can you do: nslookup barbbh1.bwes.net

 

But before we go to far, you need to create another topic in the correct board.

rahul_rtns
Frequent Advisor

Re: script regarding ssh

Hi Dennis,

 

The problem is not got ressolved. :)

 

Thank you very much for the prompt support. It was really wonderfull to learn a lot of things from you. Hope to communicate with you in near future.

 

Thanks once again..

rahul_rtns
Frequent Advisor

Re: script regarding ssh

Hi Dennis,

 

Just one more point:

 

>>cmp -s serverA_files serverB_files
if [ $? -eq 0 ]; then

In csh the statement if [ $? -eq 0 ]; is not working. May i know how to check the exit status in csh.

 

Regards,

Dennis Handly
Acclaimed Contributor

Re: script regarding ssh

>In csh the statement if [ $? -eq 0 ]; is not working. May I know how to check the exit status in csh.

 

Don't even think of using the scummy C shell.  :-(

mr google says it is something like: if ( $status == 0 ) then

rahul_rtns
Frequent Advisor

Re: script regarding ssh

I used if ($status == 0); then

But it is giving message as :

if: Empty if.

Regards,
Dennis Handly
Acclaimed Contributor

Re: script regarding ssh

>I used if ($status == 0); then

 

It looks like I was missing some spaces but that ";" shoudn't be there.

rahul_rtns
Frequent Advisor

Re: script regarding ssh

>>ls /home/rtns/testdir/*.abc | sed -e 's:.*/::g' > serverA_files
     ssh root@serverB ls "/home/rtns/a/*.abc" | grep "MPF.*\.abc" | sed -e 's:.*/MPF::g' > serverB_files
     cmp -s serverA_files serverB_files
    

Can i have the statement for matching only the last file of *.abc pattern in both the servers. Actually there are some more files afer *.abc in both the servers. So it is not working. I want to match only the last file of *.abc pattern. That will work for me..

 

Regards,

Dennis Handly
Acclaimed Contributor

Re: script regarding ssh

>Can I have the statement for matching only the last file of *.abc pattern in both the servers.

 

Just pipe it to tail:

ssh root@serverB ls "/home/rtns/a/*.abc" | grep "MPF.*\.abc" | sed -e 's:.*/MPF::g' | tail -1 > serverB_files

rahul_rtns
Frequent Advisor

Re: script regarding ssh

Hi,

 

I am having a little confusion about the feasiblity of the script that i have to prepart to match the files in two servers and if the files matched then trigger the archiving script in server A. The script that i have prepared is :

 

#!/usr/bin/csh
ls /oracle/MP1/oraarch/*.dbf | sed -e 's:.*/::g' > serverA_files
ssh root@serverB ls "/oracle/MP1/oraarch/*.dbf" | grep "MPFarch.*\.dbf" | sed -e 's:.*/MPFarch::g' > serverB_files
cmp -s serverA_files serverB_files
if ( $status == 0 ) then
/sapbasis/common_scripts/backup_archive.sh
else
comm -3 houeccp1_files austsapdr_files | mailx -s "archiving in prod failed" alias1

endif
rm -f serverA_files serverB_files

 

I am having confusion that when the files in both the servers has matched the backup_archive.sh script will run. But after comparison of the files in both the servers while the backup_archive.sh is running if a new file is generated in serverA, then that file will also get archived by the backup_archive.sh script, so will miss that newly generated file. So is there any way to reduce this risk.

 

Will really appreciate your help on this.

 

Regards,