LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2016, 06:14 PM   #1
Mike_Brown
Member
 
Registered: May 2015
Posts: 37

Rep: Reputation: Disabled
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
.

Last edited by Mike_Brown; 01-26-2016 at 10:13 PM.
 
Old 01-27-2016, 04:03 PM   #2
huffdad
Member
 
Registered: Jan 2006
Location: Missouri
Distribution: Slackware & LFS
Posts: 31

Rep: Reputation: 6
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 9 07-28-2015 04:49 PM
Bash script issue (for loop inside a loop) Mperonen Programming 3 08-08-2013 03:14 AM
[SOLVED] Using while loop & select statement - Loop issues Kustom42 Programming 4 05-17-2013 09:43 AM
[SOLVED] Bash - While Loop reading from two lists simultaneously - nested while loop wolverene13 Programming 11 10-01-2011 06:00 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration