0

I'm trying to extract some information from a list of servers and so I wrote this one liner which I will then pass through ssh user@machine 'command':

# hostname > info ; cat /etc/*-release | awk 'NR==3' >> info ; uname -a >> info ; rpm -qa >> info ; mail -s '`hostname` install list' itaig@mydomain.com < info

I've also tried:

[root@itai-test ~]# hostname > info ; cat /etc/*-release | awk 'NR==3' >> info ; uname -a >> info ; rpm -qa >> info ;hn=`/bin/hostname` ; mail -s '$hn install list' itaig@amadeus.co.il < info

But the subject looks like this: $hn install list

Itai Ganot
  • 10,644
  • 29
  • 93
  • 146

1 Answers1

1

You need to use double quotes instead of single quotes in your subject:

[root@itai-test ~]# hostname > info ; cat /etc/*-release | awk 'NR==3' >> info ; uname -a >> info ; rpm -qa >> info ;hn=`/bin/hostname` ; mail -s "$hn install list" itaig@amadeus.co.il < info

Your shell will then interpolate the $hn variable in your subject.

Cakemox
  • 25,209
  • 6
  • 44
  • 67