The UNIX and Linux Forums  
Bonjour et bienvenu par les États-Unis à la UNIX et Linux Forums! Merci de votre visite et vous joindre à notre communauté mondiale.

Go Back   Les systèmes UNIX et Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert à Expert. Apprenez avancé UNIX, des commandes UNIX, Linux, les systèmes d'exploitation, d'administration système, de la Programmation, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Plus d'UNIX et Linux Forum Sujets Vous trouverez peut-être utile
Fil Thread Starter Forum Réponses Last Post
Est-ce que Active Directory top options d'authentification sous Linux? - Recherche Enterprise Linux iBot UNIX et Linux News RSS 0 11-01-2007 02:00 AM
Est-ce que Active Directory top options d'authentification sous Linux? - Recherche Enterprise Linux iBot UNIX et Linux News RSS 0 10-29-2007 06:20 AM
besoin de script pour le littoral et des comptes d'utilisateurs inutilisés dans / export / home directory krishna176 SUN Solaris 1 03-25-2007 02:45 PM
la liste des actifs immobilisés et les comptes OS luft UNIX pour les nuls Questions et réponses 4 11-03-2005 12:33 PM
Lock-out de Mandrake 9.1 compte utilisateur alarmcall Linux 5 06-26-2004 01:38 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Recherche sur ce Thread Rate Thread Modes d'affichage
  #1 (permalink)  
Old 01-26-2004
GAMO GAMO is offline
Registered User
  
 

Join Date: Jan 2004
Messages: 1
Question Comment obtenir le statut de l'utilisateur (actifs, sans littoral, à la retraite, etc) les rapports sur Sun, HP, OSF et Linux?

Nous avons un besoin de créer des rapports sur l'état des utilisateurs sur les diverses saveurs d'Unix.
Nous aimerions obtenir un résumé du nombre de expiré, sans littoral, les handicapés, les actifs, les retraités et / ou active / déverrouillé sur chaque système, ainsi que les comptes. Nous comprenons que chaque méthode sera différente selon le système d'exploitation, les paramètres de sécurité, NIS c. locaux et méthodes comptables utilisées. Mais, comme de savoir comment les autres le font? Par exemple, en utilisant OSF / Digital Unix, un moyen serait d'utiliser les tcb edauth utilité et d'en extraire une partie de ces données sur un système de confiance. Existe-t-il des méthodes similaires pour HP, Sun, et / ou Linux?
  #2 (permalink)  
Old 01-28-2004
tikual tikual is offline
Registered User
  
 

Join Date: Nov 2003
Lieu: HK
Posts: 53
Mon premier script a été écrit il ya un an dans ce script et de m'aider à vérifier mon état de compte dans beaucoup de systèmes à distance plus facile. Cela a été mon premier script. Pas juste et bon pour votre référence.

Exigence:

1.
Obtenir un script que suivre le lien. Il s'agit d'un script dans HP célèbre forum - caljd.sh

Dans ma machine linux, j'ai besoin de modifier la première ligne de #! / Usr / bin / sh à #! / Bin / ksh

http://forums1.itrc.hp.com/service/f...13969&ext\u003d.txt

2.
Fichier de liste d'hôtes
Dans ma env, j'ai deux fichiers. L'un est appelé hp.list et un autre est sun.list.

Liste format:
host1
host2
host3
.
.

Un accueil dans une ligne

3.
Mon script stupide. Ce script est en cours d'exécution dans les machines, mais pas de contrôle sur celle-ci. Parce que dans mon env, dimanche serveur et serveur HP sont les plus importants.

A propos de l'usage: voir mon script introduction.
Code:
#!/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

Dernière édition par Optimus_P; au 01.28.2004 10:58 AM..
  #3 (permalink)  
Old 01-28-2004
tikual tikual is offline
Registered User
  
 

Join Date: Nov 2003
Lieu: HK
Posts: 53
Mon premier script a été écrit il ya un an dans ce script et de m'aider à vérifier mon état de compte dans beaucoup de systèmes à distance plus facile. Cela a été mon premier script. Pas juste et bon pour votre référence.

Exigence:

1.
Obtenir un script que suivre le lien. Il s'agit d'un script dans HP célèbre forum - caljd.sh

Dans ma machine linux, j'ai besoin de modifier la première ligne de #! / Usr / bin / sh à #! / Bin / ksh

http://forums1.itrc.hp.com/service/f...13969&ext\u003d.txt

2.
Fichier de liste d'hôtes
Dans ma env, j'ai deux fichiers. L'un est appelé hp.list et un autre est sun.list.

Liste format:
host1
host2
host3
.
.

Un accueil dans une ligne

3.
Mon script stupide. Ce script est en cours d'exécution dans les machines, mais pas de contrôle sur celle-ci. Parce que dans mon env, dimanche serveur et serveur HP sont les plus importants.

A propos de l'usage: voir mon script introduction.
Code:
#!/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

Dernière édition par Optimus_P; au 01.28.2004 10:58 AM..
  #4 (permalink)  
Old 01-28-2004
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
  
 

Join Date: Mai 2001
Lieu: Chicago, IL, Etats-Unis
Messages: 1006
l'utilisation des balises du code s'il vous plaît. \ [code \]
Closed Thread

Bookmarks

Thread Tools Recherche sur ce Thread
Recherche sur ce Thread:

Recherche avancée
Modes d'affichage Rate this thread
Rate this thread:

Règles de messages
Tu mai pas de nouvelles discussions: nonoui
Tu mai pas envoyer des réponses:
Tu mai pas envoyer des pièces jointes
Tu mai pas modifier vos messages

BB code est Sur
Smilies sont Sur
[IMG] code est Sur
Le code HTML est Hors tension
Trackbacks sont Sur
Pingbacks sont Sur
Refbacks sont Sur




Toutes les heures sont au format GMT -4. Le temps est maintenant 06:48 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traductions Langue Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
Les systèmes UNIX et Linux Forums Content Copyright © 1993-2009. Tous droits Reserved.Ad de gestion par RedTyger

Content Relevant URLs par vBSEO 3.2.0