我想创建一个php,列出SSH用户名及其过期日期。我已经编写了一个脚本来列出所有ssh用户名及其在终端中的到期日期。但我怎么能用PHP做到这一点?
#!/bin/bash
echo "-------------------------------"
echo "USERNAME EXP DATE "
echo "-------------------------------"
while read mumetndase
do
USERLIST="$(echo $mumetndase | cut -d: -f1)"
ID="$(echo $mumetndase | grep -v nobody | cut -d: -f3)"
exp="$(chage -l $USERLIST | grep "Account expires" | awk -F": " '{print $2}')"
if [[ $ID -ge 1000 ]]; then
printf "%-17s %2s\n" "$USERLIST" "$exp"
fi
done < /etc/passwd
TOTAL="$(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd | wc -l)"
echo "-------------------------------"
echo "Total Users: $TOTAL users"
echo "-------------------------------"
echo ""