首先安装fortune
sudo rpm -ivh fortune-mod-1.99.1-17.sdl7.x86_64.rpm
提示缺少依赖
warning: fortune-mod-1.99.1-17.sdl7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 41a40948: NOKEY
error: Failed dependencies:
librecode.so.0()(64bit) is needed by fortune-mod-1.99.1-17.sdl7.x86_64
安装依赖
sudo rpm -ivh librecode-3.6-alt11.1.1.x86_64.rpm
提示
Preparing... ################################# [100%]
Updating / installing...
1:librecode-3.6-alt11.1.1 ################################# [100%]
再安装fortune
sudo rpm -ivh fortune-mod-1.99.1-17.sdl7.x86_64.rpm
提示
Preparing... ################################# [100%]
Updating / installing...
1:fortune-mod-1.99.1-17.sdl7 ################################# [100%]
再安装cowsay
sudo rpm -ivh cowsay-3.04-4.el7.noarch.rpm
提示
Preparing... ################################# [100%]
Updating / installing...
1:cowsay-3.04-4.el7 ################################# [100%]
至此cowsay和fortune安装完成。
编写脚本
vi cowsay.sh
写去以下代码
#!bin/bash
# call cowsay after login
animal=$(ls /usr/share/cowsay | shuf -n 1)
declare -i name_length=${#animal}-4
# pass sentence to cowsay with random animal
echo Welcome XiaXingTao | cowsay -f ${animal:0:$name_length}
保存退出
最后将脚本文件拷贝到/etc/profile.d/目录下
cp cowsay.sh /etc/profile.d/
重新登录 大功告成
网友评论