![]() |
Hola y bienvenida de los Estados Unidos a la UNIX y Linux Foros! Gracias por su visita y formar parte de nuestra comunidad global.
|
|
google unix.com
|
|||||||
| Foros | Registro | Reglas de los Foros | Enlaces | Álbumes | Preguntas más frecuentes | Lista de miembros | Calendario | Búsqueda | Puestos de hoy | Marcar Foros Como Leídos |
| UNIX para usuarios avanzados y expertos Experto a experto. Aprender avanzada UNIX, los comandos de UNIX, Linux, Sistemas Operativos, Administración de Sistemas, Programación, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
Más UNIX y Linux Foro Temas usted puede encontrar útiles
|
||||
| Hilo | Hilo para principiantes | Foro | Respuestas | Último mensaje |
| Active Directory no superior opciones de autenticación de Linux? - Búsqueda de Enterprise Linux | iBOT | UNIX y Linux Noticias RSS | 0 | 11-01-2007 02:00 AM |
| Active Directory no superior opciones de autenticación de Linux? - Búsqueda de Enterprise Linux | iBOT | UNIX y Linux Noticias RSS | 0 | 10-29-2007 06:20 AM |
| necesidad script bloqueado y no utilizados para las cuentas de usuario en / export / home directorio | krishna176 | Sun Solaris | 1 | 03-25-2007 03:45 PM |
| lista de activos y las cuentas bloqueadas OS | Luft | UNIX for Dummies Preguntas y Respuestas | 4 | 11-03-2005 12:33 PM |
| Bloqueado de cuenta de usuario de Mandrake 9.1 | alarmcall | Linux | 5 | 06-26-2004 02:38 PM |
![]() |
|
|
Linkback vínculo | Herramientas de hilo | Buscar en este Hilo | Tasa de Hilo | Modos de visualización |
|
|
|
||||
|
Tenemos una necesidad de crear informes sobre la situación de los usuarios sobre los diversos sabores de Unix.
Nos gustaría recibir un resumen de cuántas de vencimiento, bloqueado, los discapacitados, activos, jubilados y / o activa / desbloqueado están en cada sistema, junto con el total de cuentas. Entendemos que cada método sería diferente en función de sistema operativo, la configuración de seguridad, NEI vs local, y los métodos utilizados. Pero quiero saber cómo lo están haciendo otros? Por ejemplo, utilizando OSF / Digital Unix, en un solo sentido sería utilizar el tcb edauth y utilidad para extraer algunos de estos datos en un sistema de confianza. ¿Existen métodos similares para HP, Sun, y / o Linux? |
|
||||
|
Mi primer guión fue escrito hace un año en este script y me ayudan a controlar mi estado de cuenta en muchos sistemas remotos más fácil. Ese fue mi primer guión. No es bueno y justo para su referencia.
Requisito: 1. Obtener un poderoso guión como seguir el enlace. Se trata de una secuencia de comandos en el famoso foro de HP - caljd.sh Linux en mi máquina, tengo que modificar la primera línea de #! / Usr / bin / sh a #! / Bin / ksh http://forums1.itrc.hp.com/service/f...13969&ext\u003d.txt 2. Lista de archivos de acogida En mi entorno, tengo dos archivos. Uno se llama hp.list y otra es sun.list. Formato de lista: host1 host2 host3 . . Una acogida en una línea 3. Mi estúpido guión. Este script se ejecuta en la máquina linux, pero no control sobre ella. Porque en mi entorno, el Sol y el servidor de servidor de HP son los más importantes. Sobre el uso: ver a mi script de presentación. Código:
#!/bin/ksh
##### Introduction #####
##
## This script is used for checking user login expiry date
## Get the password control files from remote according a host list
##### Requirement #####
##
## Root user can run this script only
## The following files should be existing in same directory
##
## chkpass.sh : Main Script - FTP file from remote hosts
## According different platform then has
## different formula.
##
## caljd.sh : Assistant Script - Source from public
## For calculating and converting date format.
##
## sun.list : host list of SUN platform that you wanted for checking,
## one row contains one hostname only
##
## hp.list : host list of HP platform that you wanted for checking,
## one row contains one hostname only
##### Usage #####
##
## Step 1) chkpass.sh [username] - Start to check the specified user
##
## Step 2) Login name & password - For ftp file transferring.
## (Root Privilege Account only)
## Result will be shown on screen and will be re-directed to a log also
##
trap 'print "Cancel the checking\n" ; exit 1' 2 3 9 15
USERNAME=$1
##### Check option, if no option then the default is current user #####
if [[ $# != 1 ]];
then
print "Check who?"
print "Usage: chkpass.sh [username]\n"
exit 1
else
CHKWHO=$USERNAME
fi
WORKPATH="$PWD"
SUNLIST="$WORKPATH/sun.list"
HPLIST="$WORKPATH/hp.list"
CHKLOG="$WORKPATH/${USERNAME}.result.log"
GET_UID=`id | awk -F"(" '{print$1}'`
UID=${GET_UID#*=}
if [[ ! $UID -eq 0 ]];
then
print
print "Pls. note that you need to provide"
print "root login and password for the script"
print
fi
if [[ -a $CHKLOG ]];
then
mv $CHKLOG ${CHKLOG}.old
fi
function code {
if grep -q -i "Not Connected" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m FTP connection failed\n" | tee -a $CHKLOG
elif grep -q -i "Login incorrect" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m Connection Failed. Incorrect login or password\n" | tee -a $CHKLOG
elif grep -q -i "No such file" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m Checking failed and it caused by one of following situations." | tee -a $CHKLOG
print "\033[30;43m ${HOST}: \033[0m 1. Make sure the existence of $CHKWHO in $HOST." | tee -a $CHKLOG
print "\033[30;43m ${HOST}: \033[0m 2. It doesn't a trusted system. No password setting for $CHKWHO.\n" | tee -a $CHKLOG
fi
}
if [[ ! -a $SUNLIST || ! -a $HPLIST ]];
then
print
print 'File Missing: "sun.list" & "hp.list"'
printf '%s\n%s\n%s\n%s\n\n' '#Example Content' host1 host2 host3
exit 1
fi
cat $SUNLIST $HPLIST > $WORKPATH/all.list
ALL_LIST="$WORKPATH/all.list"
print "Start to collect records from remote hosts"
read ftp_name?"Enter User Name: "
stty -echo
read ftp_pass?"Enter Password: "
stty echo
print
print
for list in `grep -v '#' $ALL_LIST`
do
HOST=$list
USER=$ftp_name
PASS=$ftp_pass
########################
##### SUN PLATFORM #####
########################
##### if - 1 #####
if grep -q $HOST $SUNLIST;
then
#This log is used for function "code"
FTPLOG="$WORKPATH/sunftp.log"
ftp -ivn << EOF > $FTPLOG 2>&1
open $HOST
user $USER $PASS
asc
cd /etc
get shadow
bye
EOF
##### if - 2 #####
if [[ -a $WORKPATH/shadow ]];
then
mv $WORKPATH/shadow $WORKPATH/${HOST}.shadow
##### if - 3 #####
if grep -q -w $CHKWHO $WORKPATH/${HOST}.shadow ;
then
typeset -i SEC_FR_70S DAY_FR_70S LAST_CHANGE LAST_CHANGE_SEC REMAINS
SEC_FR_70S=$(date +%s)
DAY_FR_70S=$((SEC_FR_70S/60/60/24))
LAST_CHANGE=$(awk -F: '/^'$CHKWHO':/ {print$3}' $WORKPATH/${HOST}.shadow)
ACC_PERIOD=$(awk -F: '/^'$CHKWHO':/ {print$5}' $WORKPATH/${HOST}.shadow)
((EXPIRATION=LAST_CHANGE+ACC_PERIOD))
((REMAINS=EXPIRATION-DAY_FR_70S))
##### if - 4 #####
if [[ $LAST_CHANGE = 0 || $ACC_PERIOD = 0 ]] || [[ -z $LAST_CHANGE || -z $ACC_PERIOD ]];
then
print "\033[37;42m ${HOST}: \033[0m No expiration date setting for $CHKWHO\n" | tee -a $CHKLOG
elif [[ $EXPIRATION -lt $DAY_FR_70S ]];
then
print "\033[37;41m ${HOST}: \033[0m $CHKWHO already expired\n" | tee -a $CHKLOG
else
EXP_JUL=$($WORKPATH/caljd.sh -n $REMAINS)
EXP_HUM=$($WORKPATH/caljd.sh $EXP_JUL)
MONTH=${EXP_HUM%% *}
DAY=$(echo $EXP_HUM | awk '{print$2}')
YEAR=${EXP_HUM##* }
print "\033[37;42m ${HOST}: \033[0m $CHKWHO will expire after $REMAINS days" | tee -a $CHKLOG
printf "%s\t%s/%s/%s\t%s\n\n" "EXPIRATION DATE:" $DAY $MONTH $YEAR "(DD/MM/YYYY)" | tee -a $CHKLOG
fi
##### if - 4 end #####
else
print "\033[30;43m ${HOST}: \033[0m $CHKWHO was not found\n" | tee -a $CHKLOG
fi
##### if - 3 end #####
rm $WORKPATH/${HOST}.shadow
else
code
fi
##### if - 2 end #####
rm $FTPLOG
else
#######################
##### HP PLATFORM #####
#######################
PREFIX=$(print $CHKWHO | cut -c 1)
#This log is used for function "code"
FTPLOG="$WORKPATH/hpftp.log"
ftp -ivn << EOF > $FTPLOG 2>&1
open $HOST
user $USER $PASS
asc
cd /tcb/files/auth/$PREFIX
get $CHKWHO
bye
EOF
##### if - 5 #####
if [[ -a $WORKPATH/$CHKWHO ]];
then
mv $WORKPATH/$CHKWHO $WORKPATH/${HOST}.${CHKWHO}
typeset -i SEC_FR_70S DAY_FR_70S CHG_DATE ACC_DATE EXPIRATION REMAINS
SEC_FR_70S=$(date +%s)
SUC_CHG=$(awk -F"u_succhg#" '/u_succhg/ {print$2}' $WORKPATH/${HOST}.${CHKWHO})
CHG_DATE=${SUC_CHG%%:*}
ACC_PERIOD=$(awk -F"u_exp#" '/u_exp/ {print$2}' $WORKPATH/${HOST}.${CHKWHO})
ACC_DATE=${ACC_PERIOD%%:*\\}
((EXPIRATION=CHG_DATE+ACC_DATE))
((REMAINS=EXPIRATION-SEC_FR_70S))
CHG_TO_DAY=$((REMAINS/60/60/24))
##### if - 6 #####
if [[ $CHG_DATE = 0 || $ACC_DATE = 0 ]] || [[ -z $CHG_DATE || -z $ACC_DATE ]] ;
then
print "\033[37;42m ${HOST}: \033[0m No expiration date setting for $CHKWHO\n" | tee -a $CHKLOG
elif [[ $EXPIRATION -lt $SEC_FR_70S ]];
then
print "\033[37;41m ${HOST}: \033[0m $CHKWHO already expired\n" | tee -a $CHKLOG
else
EXP_JUL=$($WORKPATH/caljd.sh -n $CHG_TO_DAY)
EXP_HUM=$($WORKPATH/caljd.sh $EXP_JUL)
MONTH=${EXP_HUM%% *}
DAY=$(echo $EXP_HUM | awk '{print$2}')
YEAR=${EXP_HUM##* }
print "\033[37;42m ${HOST}: \033[0m $CHKWHO will expire after $CHG_TO_DAY" days | tee -a $CHKLOG
printf "%s\t%s/%s/%s\t%s\n\n" "EXPIRATION DATE:" $DAY $MONTH $YEAR "(DD/MM/YYYY)" | tee -a $CHKLOG
fi
##### if - 6 end #####
rm $WORKPATH/${HOST}.${CHKWHO}
else
code
fi
##### if - 5 end #####
rm $FTPLOG
fi
##### if - 1 end #####
done
rm $ALL_LIST
print "Checking completed" | tee -a $CHKLOG
Última edición por Optimus_P; al 01-28-2004 10:58 AM.. |
|
||||
|
Mi primer guión fue escrito hace un año en este script y me ayudan a controlar mi estado de cuenta en muchos sistemas remotos más fácil. Ese fue mi primer guión. No es bueno y justo para su referencia.
Requisito: 1. Obtener un poderoso guión como seguir el enlace. Se trata de una secuencia de comandos en el famoso foro de HP - caljd.sh Linux en mi máquina, tengo que modificar la primera línea de #! / Usr / bin / sh a #! / Bin / ksh http://forums1.itrc.hp.com/service/f...13969&ext\u003d.txt 2. Lista de archivos de acogida En mi entorno, tengo dos archivos. Uno se llama hp.list y otra es sun.list. Formato de lista: host1 host2 host3 . . Una acogida en una línea 3. Mi estúpido guión. Este script se ejecuta en la máquina linux, pero no control sobre ella. Porque en mi entorno, el Sol y el servidor de servidor de HP son los más importantes. Sobre el uso: ver a mi script de presentación. Código:
#!/bin/ksh
##### Introduction #####
##
## This script is used for checking user login expiry date
## Get the password control files from remote according a host list
##### Requirement #####
##
## Root user can run this script only
## The following files should be existing in same directory
##
## chkpass.sh : Main Script - FTP file from remote hosts
## According different platform then has
## different formula.
##
## caljd.sh : Assistant Script - Source from public
## For calculating and converting date format.
##
## sun.list : host list of SUN platform that you wanted for checking,
## one row contains one hostname only
##
## hp.list : host list of HP platform that you wanted for checking,
## one row contains one hostname only
##### Usage #####
##
## Step 1) chkpass.sh [username] - Start to check the specified user
##
## Step 2) Login name & password - For ftp file transferring.
## (Root Privilege Account only)
## Result will be shown on screen and will be re-directed to a log also
##
trap 'print "Cancel the checking\n" ; exit 1' 2 3 9 15
USERNAME=$1
##### Check option, if no option then the default is current user #####
if [[ $# != 1 ]];
then
print "Check who?"
print "Usage: chkpass.sh [username]\n"
exit 1
else
CHKWHO=$USERNAME
fi
WORKPATH="$PWD"
SUNLIST="$WORKPATH/sun.list"
HPLIST="$WORKPATH/hp.list"
CHKLOG="$WORKPATH/${USERNAME}.result.log"
GET_UID=`id | awk -F"(" '{print$1}'`
UID=${GET_UID#*=}
if [[ ! $UID -eq 0 ]];
then
print
print "Pls. note that you need to provide"
print "root login and password for the script"
print
fi
if [[ -a $CHKLOG ]];
then
mv $CHKLOG ${CHKLOG}.old
fi
function code {
if grep -q -i "Not Connected" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m FTP connection failed\n" | tee -a $CHKLOG
elif grep -q -i "Login incorrect" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m Connection Failed. Incorrect login or password\n" | tee -a $CHKLOG
elif grep -q -i "No such file" $FTPLOG;
then
print "\033[30;43m ${HOST}: \033[0m Checking failed and it caused by one of following situations." | tee -a $CHKLOG
print "\033[30;43m ${HOST}: \033[0m 1. Make sure the existence of $CHKWHO in $HOST." | tee -a $CHKLOG
print "\033[30;43m ${HOST}: \033[0m 2. It doesn't a trusted system. No password setting for $CHKWHO.\n" | tee -a $CHKLOG
fi
}
if [[ ! -a $SUNLIST || ! -a $HPLIST ]];
then
print
print 'File Missing: "sun.list" & "hp.list"'
printf '%s\n%s\n%s\n%s\n\n' '#Example Content' host1 host2 host3
exit 1
fi
cat $SUNLIST $HPLIST > $WORKPATH/all.list
ALL_LIST="$WORKPATH/all.list"
print "Start to collect records from remote hosts"
read ftp_name?"Enter User Name: "
stty -echo
read ftp_pass?"Enter Password: "
stty echo
print
print
for list in `grep -v '#' $ALL_LIST`
do
HOST=$list
USER=$ftp_name
PASS=$ftp_pass
########################
##### SUN PLATFORM #####
########################
##### if - 1 #####
if grep -q $HOST $SUNLIST;
then
#This log is used for function "code"
FTPLOG="$WORKPATH/sunftp.log"
ftp -ivn << EOF > $FTPLOG 2>&1
open $HOST
user $USER $PASS
asc
cd /etc
get shadow
bye
EOF
##### if - 2 #####
if [[ -a $WORKPATH/shadow ]];
then
mv $WORKPATH/shadow $WORKPATH/${HOST}.shadow
##### if - 3 #####
if grep -q -w $CHKWHO $WORKPATH/${HOST}.shadow ;
then
typeset -i SEC_FR_70S DAY_FR_70S LAST_CHANGE LAST_CHANGE_SEC REMAINS
SEC_FR_70S=$(date +%s)
DAY_FR_70S=$((SEC_FR_70S/60/60/24))
LAST_CHANGE=$(awk -F: '/^'$CHKWHO':/ {print$3}' $WORKPATH/${HOST}.shadow)
ACC_PERIOD=$(awk -F: '/^'$CHKWHO':/ {print$5}' $WORKPATH/${HOST}.shadow)
((EXPIRATION=LAST_CHANGE+ACC_PERIOD))
((REMAINS=EXPIRATION-DAY_FR_70S))
##### if - 4 #####
if [[ $LAST_CHANGE = 0 || $ACC_PERIOD = 0 ]] || [[ -z $LAST_CHANGE || -z $ACC_PERIOD ]];
then
print "\033[37;42m ${HOST}: \033[0m No expiration date setting for $CHKWHO\n" | tee -a $CHKLOG
elif [[ $EXPIRATION -lt $DAY_FR_70S ]];
then
print "\033[37;41m ${HOST}: \033[0m $CHKWHO already expired\n" | tee -a $CHKLOG
else
EXP_JUL=$($WORKPATH/caljd.sh -n $REMAINS)
EXP_HUM=$($WORKPATH/caljd.sh $EXP_JUL)
MONTH=${EXP_HUM%% *}
DAY=$(echo $EXP_HUM | awk '{print$2}')
YEAR=${EXP_HUM##* }
print "\033[37;42m ${HOST}: \033[0m $CHKWHO will expire after $REMAINS days" | tee -a $CHKLOG
printf "%s\t%s/%s/%s\t%s\n\n" "EXPIRATION DATE:" $DAY $MONTH $YEAR "(DD/MM/YYYY)" | tee -a $CHKLOG
fi
##### if - 4 end #####
else
print "\033[30;43m ${HOST}: \033[0m $CHKWHO was not found\n" | tee -a $CHKLOG
fi
##### if - 3 end #####
rm $WORKPATH/${HOST}.shadow
else
code
fi
##### if - 2 end #####
rm $FTPLOG
else
#######################
##### HP PLATFORM #####
#######################
PREFIX=$(print $CHKWHO | cut -c 1)
#This log is used for function "code"
FTPLOG="$WORKPATH/hpftp.log"
ftp -ivn << EOF > $FTPLOG 2>&1
open $HOST
user $USER $PASS
asc
cd /tcb/files/auth/$PREFIX
get $CHKWHO
bye
EOF
##### if - 5 #####
if [[ -a $WORKPATH/$CHKWHO ]];
then
mv $WORKPATH/$CHKWHO $WORKPATH/${HOST}.${CHKWHO}
typeset -i SEC_FR_70S DAY_FR_70S CHG_DATE ACC_DATE EXPIRATION REMAINS
SEC_FR_70S=$(date +%s)
SUC_CHG=$(awk -F"u_succhg#" '/u_succhg/ {print$2}' $WORKPATH/${HOST}.${CHKWHO})
CHG_DATE=${SUC_CHG%%:*}
ACC_PERIOD=$(awk -F"u_exp#" '/u_exp/ {print$2}' $WORKPATH/${HOST}.${CHKWHO})
ACC_DATE=${ACC_PERIOD%%:*\\}
((EXPIRATION=CHG_DATE+ACC_DATE))
((REMAINS=EXPIRATION-SEC_FR_70S))
CHG_TO_DAY=$((REMAINS/60/60/24))
##### if - 6 #####
if [[ $CHG_DATE = 0 || $ACC_DATE = 0 ]] || [[ -z $CHG_DATE || -z $ACC_DATE ]] ;
then
print "\033[37;42m ${HOST}: \033[0m No expiration date setting for $CHKWHO\n" | tee -a $CHKLOG
elif [[ $EXPIRATION -lt $SEC_FR_70S ]];
then
print "\033[37;41m ${HOST}: \033[0m $CHKWHO already expired\n" | tee -a $CHKLOG
else
EXP_JUL=$($WORKPATH/caljd.sh -n $CHG_TO_DAY)
EXP_HUM=$($WORKPATH/caljd.sh $EXP_JUL)
MONTH=${EXP_HUM%% *}
DAY=$(echo $EXP_HUM | awk '{print$2}')
YEAR=${EXP_HUM##* }
print "\033[37;42m ${HOST}: \033[0m $CHKWHO will expire after $CHG_TO_DAY" days | tee -a $CHKLOG
printf "%s\t%s/%s/%s\t%s\n\n" "EXPIRATION DATE:" $DAY $MONTH $YEAR "(DD/MM/YYYY)" | tee -a $CHKLOG
fi
##### if - 6 end #####
rm $WORKPATH/${HOST}.${CHKWHO}
else
code
fi
##### if - 5 end #####
rm $FTPLOG
fi
##### if - 1 end #####
done
rm $ALL_LIST
print "Checking completed" | tee -a $CHKLOG
Última edición por Optimus_P; al 01-28-2004 10:58 AM.. |
|
||||
|
uso de etiquetas de código por favor. \ [código \]
|
![]() |
| Marcadores |
| Herramientas de hilo | Buscar en este Hilo |
| Modos de visualización | Vota a este hilo |
|
|