Post date: Aug 31, 2015 1:33:53 PM
%利用函式判斷是否為 linux 系統,如果是 linux 系統則印出主機名稱
\IfFileExists{/etc/hostname}{ %如果 /etc/hostname 存在則
\usepackage{catchfile} %使用讀取檔案
\CatchFileDef{\hname}{/etc/hostname}{} %定義 \hname 為 /etc/hostname 中的內容
}{ %
\usepackage{catchfile} %如果 /etc/hostname 不存在則
\CatchFileDef{\hname}{./non-host.tex}{} %定義 \hname 為 non-host.tex 中的內容
}
\hname %將此變數放在想顯示主機名稱的地方