Zend certified PHP/Magento developer

Pull dmidecode info over SSH and save info to local file with hostname entry

Scripting is not my strong suite, but I’m trying to learn.

Trying to pull dmidecode info, specifically ‘Product’ from the dmidecode output, on remote systems from the main server, and save the info into a local file on the server with each entry noted by the remote hostname being accessed via SSH.

This is what I have so far in my script:

for i in `{cat /home/file_with_hostnames}`; do ssh $i "dmidecode | grep Prod"; done

When I run the above, I get an output looking like this for each entry in ‘file_with_hostnames’ on the servers stdout:

Product Name: Elo AiO

Product Name: Elo AiO

Product Name: Elo AiO

However, each entry is not noted with the hostname being connected to, which is read from the file /home/file_with_hostnames. I would like the info that I pull to be stored in a file with each computer name being connected to, running the dmidecode | grep Prod command.

For example, I would like the info to look something like this:

PC1 - Product Name: Elo AiO

PC2 - Product Name: Elo AiO

etc… as indicated by the /home/file_with_hostnames file.

Timestamps are not that vital, but if they could be included as well, that would be great.