Operating System - HP-UX
1838134 Members
4448 Online
110124 Solutions
New Discussion

Re: Help me please .....i am newbie

 
morganelan
Trusted Contributor

Help me please .....i am newbie

I have 3 Servers : 100.100.102.6
100.100.102.7
100.100.102.9
100.100.100.222
I want to make script to extract *.tar file
that placed on 100.100.100.222 to 3 other servers (100.100.102.6;100.100.102.7 and 100.100.102.9) at once running script.
If I want run that script on 100.100.102.7, how to make this work?

In manually I use this statement:

on 100.100.102.6 machine :
$pwd
$/u/pusat
$ftp 100.100.100.222
220 appr FTP server (Version 1.1.214.5 Tue Nov 16 09:39:15 GMT 19.
Name (100.100.100.203:lin): kamal
Password : kamal
230 User kamal logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>pwd
"/u/linkdev" is current directory.
ftp>cd bawa
250 CWD command successful.
ftp>mget AR072.tar AR083.tar IV075.tar
mget AR072.tar ? y
200 PORT command successful.
150 Opening BINARY mode data connection for IV018.tar (60928 bytes).
226 Transfer complete.
60928 bytes received in 0.1 seconds (595.00 Kbytes/s)
.....
.....
ftp>bye
$pwd
$/u/pusat
$tar xvf IV075.tar
tar: blocksize = 20
x clientproc/IV075.p, 13071 bytes, 26 tape blocks
x clientproc/IV075a.p, 8926 bytes, 18 tape blocks
x proc/IV075aload.p, 1123 bytes, 3 tape blocks
x proc/IV075bload.p, 3101 bytes, 7 tape blocks
x proc/IV075del.p, 1396 bytes, 3 tape blocks
x proc/IV075load.p, 1314 bytes, 3 tape blocks
x proc/IV075save.p, 4528 bytes, 9 tape blocks

I repeat the above proseses on 100.100.102.7 and 100.100.102.9 machines.

How to make one script that running on one of the 3 servers above to make extract *.tar file
that get from 100.100.100.222 machine.

Example if on 100.100.100.222 in directori /u/linkdev/bawa have AR072.tar IV068.tar MT065.tar then I execute script
that will ask me like this:

Need to extract what file ?
AR072.tar;AR089.tar;IV090.tar;etc then push Enter, after that the script automatic running
on 100.100.102.6 /u/pusat:
$tar xvf AR072.tar
$tar xvf AR089.tar
$tar xvf IV090.tar
on 100.100.102.7 /u/depo:
$tar xvf AR072.tar
$tar xvf AR089.tar
$tar xvf IV090.tar
on 100.100.102.9 /u/depo1:
$tar xvf AR072.tar
$tar xvf AR089.tar
$tar xvf IV090.tar

Please help me .......becoz i am newbie



Kamal Mirdad
4 REPLIES 4
Rajeev  Shukla
Honored Contributor

Re: Help me please .....i am newbie

Hi Kamal,
First is to configure rcp access on all the four servers. i.e from 100.100.102.7 configure rcp access to all other 3 servers.
Do this using /etc/hosts.equiv or .rhosts of the user by which you will be running the rcp script.
Then write a script which does rcp some thing like
rcp 100.100.100.222:/u/linkdev/bawa/*.tar 100.100.102.6:/u/pusat
have this line for each servers and then run remsh 100.100.102.6 -n "cd /u/pusat; tar xvf ....."

and do this too on all servers so rcp and remsh will solve all u'r purpose from one server. Have this script run on 100.100.102.7.
let me know if u need more help..

rajeev
Jose Mosquera
Honored Contributor

Re: Help me please .....i am newbie

Hi,

From your "100.100.102.222" machine:
#Script Start
PARAMS="100.100.100.6:pusat 100.100.102.7:depo 100.100.102.9:depo1"
cd /u/linkdev/bawa
for PARAM in $PARAMS
do
SERVER=`echo $PARAM|awk -F":" '{ print $1 }'`
DIR=`echo $PARAM|awk -F":" '{ print $2 }'`
rcp *.tar $SERVER@root:/u/$DIR
echo "Need to extract Tar's files? (Y/N) \c"
read ANSW
if [ $ANS = "Y" ]
then
remsh $SERVER -l root -n 'cd /u/$DIR;tar xf *.tar'
fi
done
#Script End

To use rcp/remsh commands successfully you need create in the root user home directory of each target machines (100.100.100.6 100.100.102.7 100.100.102.9) a file named .rhosts, you can do this in each machine under root login by the following commands:

#cd
#echo "100.100.102.222 root" > .rhosts
#chmod 555 .rhosts
#chown root:sys .rhosts

After this, the above scriptfile should work without problems.

I hope to have understood you and that my answer is useful for you. If you require some adjustment you don't doubt to tell it to me,

Rgds.
Jose Mosquera
Honored Contributor

Re: Help me please .....i am newbie

Hi again,

Pls be careful with the ./rhosts treatment, to prevent an overwrite action I prefer that use the following action instead:
#echo "100.100.102.222 root" >> .rhosts

With ">>" you append a new line on .rhosts file, if the file not exist you will create anyway.

To improve the script question message use:
echo "Need to extract Tar's files into $PARAM node? (Y/N) \c"

Remember, you must set executable permission at script file: chmod 755

This procedure has been thought to be executed by the user "root".

Rgds.
Steven E. Protter
Exalted Contributor

Re: Help me please .....i am newbie

If you want to do it secure without passwords, install this:

https://payment.ecommerce.hp.com/cgi-bin/swdepot_parser.cgi/cgi/try.pl?productNumber=T1471AA&date=

follow the attached document to exchang public keys.

Good Luck.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com