我编写了Greeting.sh脚本,我不明白如何在退出命令上执行脚本,我尝试将其分配给变量,然后更改该变量的访问权限,但它不起作用。
#!/bin/bash
time=`date|cut -f5 -d " "`
hrs=`echo $time|cut -f1 -d ":"`
min=`echo $time|cut -f2 -d ":"`
time1=`who|cut -f13 -d " "`
hrs1=`echo $time1|cut -f1 -d ":"`
min1=`echo $time1|cut -f2 -d ":"`
h=`expr $hrs - $hrs1`
m=`expr $min - $min1`
for ((i=0;i<50;i++))
do
echo -ne "*"
done
echo ""
echo "Welcome to SLIIT $HOSTNAME Server!"
echo "You have spent $h hours and $m minutes with us."
echo "Goobye..! $LOGNAME"
for ((i=0;i<50;i++))
do
echo -ne "*"
done
echo ""
我尝试像这样分配
[ishIlan@localhost ~]$ chmod 777 Greeting.sh
[ishIlan@localhost ~]$ exit=`Greeting.sh`
[ishIlan@localhost ~]$ chmod 777 $exit
[ishIlan@localhost ~]$ $exit
如果终端上输入“exit”,我该怎么办才能使程序运行,请帮帮我。