shell script to collect information from current and remote unix boxes

I am using AIX 5.3.0.0 ; I need a script to find out each remote AIX boxes
Hostname, Model name and Serial number in following format

Hostname   Modelname      SerialID 
AIXMC01    IBM,7026-B80   IBM,0110BBA1F
AIXMC02    IBM,7026-H50   IBM,0110BBA56
AIXMC03    IBM,7026-H50   IBM,0110BBARR
AIXMC04    IBM,7026-B80   IBM,0110BBA43

From the following command I can get the info of the modelname and Serial #
(systemid has the info of the serial #)

>lsattr -Elsys0

systemid        IBM,0110BBA2F      
modelname       IBM,7026-B80       

Thank you for you help

Try this, not tested. I am assuming that ssh passwordless is setup

for h in AIXMC01 AIXMC02 AIXMC03 AIXMC04
do
  ssh $h lsattr -Elsys0 | awk -v h=$h '
BEGIN { print "Hostname Modelname SerialID" }
$1=="systemid"{s=$2}
$1=="modelname"{m=$2}
END {print h,m,s}'
done

Each box has username and password and password changes every 60 days; I can hardcode the username and passwd.

Thanks,

---------- Post updated at 10:49 AM ---------- Previous update was at 10:43 AM ----------

If run the script just for one box AIXMC01 (local; not remote) it prompt for passwd.

---------- Post updated at 10:49 AM ---------- Previous update was at 10:49 AM ----------

If run the script just for one box AIXMC01 (local; not remote) it prompt for passwd.

---------- Post updated at 11:00 AM ---------- Previous update was at 10:49 AM ----------

The problem is i cant hardcode the passwd for each box using my own userid; each box use secure ID.
secure ID contain 6digit + PIN.

But the best solution is I can get root passwd for each box;
I would like to hard code root passwd; root passwd dont required secure ID but they changes every 30 days; when they change I will change the script.

You don't have to hardcode the password. Keys are a separate mechanism. Changing the password doesn't break the key. Google 'passwordless ssh' and you'll find hundreds of examples.

This is much easier than trying to inject plaintext passwords into a script, too, because ssh(and most other sane authentication systems) is designed to prevent that for security reasons.

Thanks,

Actually I found a way to ssh without passwd to any remote boxes.
the following command " sudo su - "
now please help me to to put this logic (sudo su - ) in above script so that I can access each boxes.

thanks.

Using a passwordless ssh is far more suitable you know...
Search the forums on how to achieve this (exchange of public keys...))

As I mentioned passwordless ssh already in place.
When I enter : sudo su -
I can ssh to any boxes I like.
I need help to add sudo su - logic in the script for each boxes.

for h in AIXMC01 AIXMC02 AIXMC03 AIXMC04
do
  ssh $h lsattr -Elsys0 | awk -v h=$h '
BEGIN { print "Hostname Modelname SerialID" }
$1=="systemid"{s=$2}
$1=="modelname"{m=$2}
END {print h,m,s}'
done

Thanks,

---------- Post updated at 03:00 PM ---------- Previous update was at 02:45 PM ----------

the above script works fine when I logged as a root. the only problem I have
I dont want the heading for each boxes. As you can see "Hostname Modelname SerialID
" is repeating

Hostname   Modelname      SerialID 
AIXMC01    IBM,7026-B80   IBM,0110BBA1F
Hostname   Modelname      SerialID
AIXMC02    IBM,7026-H50   IBM,0110BBA56
Hostname   Modelname      SerialID
AIXMC03    IBM,7026-H50   IBM,0110BBARR
Hostname   Modelname      SerialID
AIXMC04    IBM,7026-B80   IBM,0110BBA43

If you don't want it to print the heading, don't print the heading... Print it yourself, before the loop, in the shell.

basically I need sort to numeerically
sort -n | uniq in the script.

Sort what numerically? None of those columns are numerals...

sort hostname in numerically:

Hostname   Modelname      SerialID 
AIXMC01    IBM,7026-B80   IBM,0110BBA1F
AIXMC02    IBM,7026-H50   IBM,0110BBA56
AIXMC03    IBM,7026-H50   IBM,0110BBARR
AIXMC04    IBM,7026-B80   IBM,0110BBA43

after running the script I can sort them; I have to take another steps.
All I need to sort hostname numerically and not to repeat the heading.

Thanks.

Print the header separately, then pipe the code block producing this output through sort...

OMG!!!! Really???