Operating System - HP-UX
1836633 Members
1693 Online
110102 Solutions
New Discussion

Re: Scripting for rhosts format

 
SOLVED
Go to solution
Dewa Negara_4
Regular Advisor

Scripting for rhosts format

Hi All,

I want to create a script to generate a neat report for my all rhosts file. For instance, I have a rhosts file as below :

#cat /root/.rhosts

bdhp4337.na.pg.com root
192.44.190.109 root
rshj root # 03152004:RSHJ reporting tool:paul@test.com:NEVER:john@test.com
bdhp4259 root # 03172004:NP1 database server:paul@test.com:NEVER:john@test.com

and I want to generate a report with format as below :

Remote server UserID Justification
-------------------------------------------------------
bdhp4337 root
192.44.190.109 root
rshj root # 03152004:RSHJ reporting tool:paul@test.com:NEVER:john@test.com
bdhp4259 root # 03172004:NP1 database server:paul@test.com:NEVER:john@test.com

How can I do that using a shell scripting?

Pls help. High score will be given.

Best Regards,
Dewa


Santos
3 REPLIES 3
Dewa Negara_4
Regular Advisor

Re: Scripting for rhosts format

Hi, Sorry...the attached output is not so clear.

The format should be :

Remote server UserID Justification
bdhp4337 root
192.44.190.109 root

rshj root # 03152004:...
bdhp4259 root # 03172004:...
Santos
Nguyen Anh Tien
Honored Contributor

Re: Scripting for rhosts format

Hi Dewa
.rhosts file is setting permission for rcp (remote copy).
It is hard to understand for me.
If you want to create script copy file from serverA to serverB.
On serverB edit ~.rhosts file
#vi ~.rhosts
serverA root
at serverA:
#rcp -r -p /path/file_or_dir serverB:/path/
HTH
tienna
HP is simple
Keith Bryson
Honored Contributor
Solution

Re: Scripting for rhosts format

Hi Dewa

If I understand correctly (I hope I do!) try this:

#!/bin/ksh
echo "HOST\tUSER\tCOMMENT" >/tmp/report
cat /root/.rhosts | while read HOST USER COMM
do
COMMENT=`echo $COMM | sed 's/ /_/g'`
echo "$HOST\t$USER\t$COMMENT" >>/tmp/report
done
cat /tmp/report | pr -e15

Note:- We have to pump the comment field through 'sed' to get rid of the spaces. This would cause the output to look strange. You may need to scroll-up to view the output as 'pr' paginates the file.

Best regards - Keith
Arse-cover at all costs