Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.