I want to search different packages in multiple servers in Solaris 10. One file contains the package information, another file contains the server information.
I have tried this:
bash-3.00# cat pk
"VRTSvcs|VRTSvxfen"
"SUNWfmd|SUNWfsmgtr"
bash-3.00# cat ser
mokshi
niki
This is my script:
bash-3.00# cat tt
#!/usr/bin/bash
>output
for j in `cat ser`
do
for ip in `cat pk`
do
M=`ssh $j "pkginfo |egrep $ip |cut -d \" \" -f7 "`;
echo "$j " >>output
echo "$M" >>output
done
done
The expected output is
cat output
bash-3.00# cat output
moksha
VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen
niki
SUNWfmd
SUNWfmdr
SUNWfsmgtr
but when I run the script it is running twice like this:
bash-3.00# bash -x tt
++ cat ser
+ for j in '`cat ser`
'
++ cat pk
+ for ip in '`cat pk`'
++ ssh mokshi 'pkginfo |egrep "VRTSvcs|VRTSvxfen" |cut -d " " -f7 '
Password:
+ M='VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen'
+ echo 'mokshi '
+ echo 'VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen'
+ for ip in '`cat pk`'
++ ssh mokshi 'pkginfo |egrep "SUNWfmd|SUNWfsmgtr" |cut -d " " -f7 '
Password:
+ M='SUNWfmd
SUNWfmdr
SUNWfsmgtr'
+ echo 'mokshi '
+ echo 'SUNWfmd
SUNWfmdr
SUNWfsmgtr'
+ for j in '`cat ser`'
++ cat pk
+ for ip in '`cat pk`'
++ ssh niki 'pkginfo |egrep "VRTSvcs|VRTSvxfen" |cut -d " " -f7 '
Password:
+ M='VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen'
+ echo 'niki '
+ echo 'VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen'
+ for ip in '`cat pk`'
++ ssh niki 'pkginfo |egrep "SUNWfmd|SUNWfsmgtr" |cut -d " " -f7 '
Password:
+ M='SUNWfmd
SUNWfmdr
SUNWfsmgtr'
+ echo 'niki '
+ echo 'SUNWfmd
SUNWfmdr
SUNWfsmgtr'
And I am getting output like this:
bash-3.00# cat output
moksha
VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen
moksha
SUNWfmd
SUNWfmdr
SUNWfsmgtr
niki
VRTSvcs
VRTSvcsag
VRTSvcsea
VRTSvxfen
niki
SUNWfmd
SUNWfmdr
SUNWfsmgtr
The main goal of the script is that its take one server from server file and it has to search first line in package file. The it has to take second server name from server name and it searches for second line in package file.
please help me where I made a mistake.