LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Revised: how to filter the host which is being used by others (https://www.linuxquestions.org/questions/linux-newbie-8/revised-how-to-filter-the-host-which-is-being-used-by-others-4175567969/)

Mike_Brown 01-26-2016 05:14 PM

Revised: how to filter the host which is being used by others
 
I would like to check whether others are log in the host or not. I have following tcsh script . **I would like to filter the host which is used by other users.** **I am using tcsh**.

Code:

host_list="/home/campus27/zwang10/bin/hostlist"
    HOSTS=`cat $host_list`
    cp /dev/null hostlist_available
    for line in $HOSTS
    do
    ssh -o ConnectTimeout=1s $line true &>/dev/null
    RESULT=$?
    if [ $RESULT -eq 0 ]
    then
    echo $line
    echo $line >> hostlist_available
    fi
    done


The above script will write all available hostname into
Code:

hostlist_available
.

But some other people are log in the available hosts. I would like to delete those hosts (except me). My username is
Code:

zwang10
.

huffdad 01-27-2016 03:03 PM

If I am reading your post correctly, then try changing this:
Code:

HOSTS=`cat $host_list`
to this:
Code:

HOSTS=`grep zwang10 $host_list`
If this is not what you are asking, please rephrase your question.


All times are GMT -5. The time now is 10:58 PM.