我试图从服务器列表中提取一些信息,所以我写了这一行,然后通过ssh user@machine 'command'传递:
# hostname > info ; cat /etc/*-release | awk 'NR==3' >> info ; uname -a >> info ; rpm -qa >> info ; mail -s '`hostname` install list' [email protected] < info
我也试过:
[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' [email protected] < info
但是这个主题看起来像这样: $hn install list
您需要在主题中使用双引号而不是单引号:
[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" [email protected] < info
然后你的shell会在你的主题中插入$hnvariables。