#!/bin/bash # pw_stat_list.sh home=/home this_script=$0 # remove ./ from script name base2=`basename "${this_script}"` # remove .sh from script name base=`echo "${base2}" | cut -d. -f1` if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi pid=$$ outfile=${base}_out_${pid}.txt datestring=$(date +"%Y-%m-%d") hozt=`hostname` echo "$hozt $datestring"> $outfile echo "" >> $outfile # view password info for each user for i in ${home}/*; do j=`echo "$i" |cut -d/ -f3` echo "chage -l $j" >> $outfile k_array=`(chage -l $j)` printf '%s\n' "${k_array[@]}" >> $outfile echo >> $outfile done echo echo "See output in $outfile" echo exit