I have taken all active user list and passing it to below code
I got below O/P
But is I harcode the finger command like
getting below O/P
Moderator's Comments:
This posting was originally posted as a follow up to a related thread. A new thread was created because this is a new issue.
Was usr an exported variable in the shell that invoked your script? I assume that it was not; so you effectively have a loop that runs the command:
one time for every word in the file sample.out. Each time you invoke this command, the contents of the file report.txt is overwritten. As a wild guess, I would think that the following might come closer to providing the output you were trying to produce:
Last edited by Don Cragun; 02-19-2014 at 11:24 PM..
Reason: Add color to show relationship between read variable name and the argument to finger.
This User Gave Thanks to Don Cragun For This Post:
Actucally I am getting
by select query, the query will retrive active users and I am passing those active users to
command to list their last user id detials.
Do you see any difference between:
and:
Reading into a variable name (usr) and reading into a variable named by the output of the command substitution of the expansion of a variable name (`${usr}`) are two COMPLETELY different things.
Passing the expansion of a variable name as an argument ("${usr}") and passing the output of the command substitution of the expansion of a variable name (`${usr}`) are two COMPLETELY different things.
Single quotes, back quotes, and double quotes all have meaning to the shell; and they all mean different things. Back quotes and double quotes ARE NOT INTERCHANGEABLE! Please try running the script I suggested (without changing it) and see if the results are different.
And, no, that is not what your script was doing. Your originally posted script executed the command:
once for each word in sample.out. (It sets the variable i to a different word in sample.out each time through the loop, but after setting the variable i, you never referenced it. It never set the variable usr, so the expansion of that variable ($usr) expanded to nothing.)
This User Gave Thanks to Don Cragun For This Post:
I ran as you suggested, it is passing row by row with user id as attached below
but when I open the file I got
The trace output shown above does not match the contents of report.txt shown above! (The login names shown in the output do not match the arguments passed to finger in the trace.)
But, it is obvious that your input file contains data with lines in the following format:
rather than lines with the format:
which was what I expected when you said you had an active user list.
Change the:
in the script to:
and then try running the script again.
This User Gave Thanks to Don Cragun For This Post:
Hi
Does anyone know if there is anyway of doing the finger command for all user id's in my enviroment. What I need to obtain is the full names of all users on the system.
I know if i do the finger command with no arguments it will list users currently logged in, but i need all users...
... (2 Replies)
Two things : On the first place i am really desperate, on the second i am about to throw my laptop away to the recycle bin in a while.
Ok now that i expressed my feeling let me describe you this mad situation.
Code:
print $1;
("finger -m " $1 "| head -1") | getline userinfo
print... (6 Replies)
I want to know the correct version of how i should use the finger command in this example below.(os is debian lenny)
(nymserver.pl is located in /home/nymserv directory.)
the two versions are :
(in/etc/inetd.conf)
finger stream tcp nowait nymuser /usr/nym/nymserv nymserv... (3 Replies)
Is there any possible way to get rid of the header when I do finger ?
I want to get rid of
Login Name Tty Idle Login Time Office Office Phone
as the header.
Please let me know how to do it. (2 Replies)
Hi,
iam using sunsolaris.
when you type finger command -- it dispalys information about local and remote users.
but here it shows as can't stat /dev/gold:8664
can anybody help what is the solution for this error.
previously the output came.
thanks,
shan (1 Reply)
Hello all,
Here is what I am trying to do. If a user exist, then send an echo "EXIST" or else "DOES NOT EXIST". (under HP-UX)
Kind of:
#!/usr/bin/sh
USER=mylogin
finger $USER
if $? = 0
then
echo "EXIST""
else
echo "DOES NOT EXIST"
fi (10 Replies)
Hey, I was wondering If anybody knew of a way to make a log of all users who type the command finger username when username is my own.
I would like to see who is keeping track of me :)
Thanks (3 Replies)
is there a way to show information on all the users on your system? when i use 'finger' is only shows users names and info who are currently on the system. is there a way to show all accounts? thanx! (5 Replies)
Hi, I've been using unix at college for a few weeks now and I have come up against a few stumbling blocks:
- Most unix commands seem to work w/ regexps - the computers I and my group are allowed to logon to are all itsunXX where XX is a number. if I can {finger @itsun88} to find out that I and... (1 Reply)