alt.os.linux.ubuntu
who command date format in script
I have a killuser script that fails only on two 10.04 LTS machines
because the date format in the who command is different. What is odd is
that from the command prompt it is correct:
guest tty7 2011-10-13 14:12 old 1291 (:0)
But in the script the time format get changed!
guest tty7 Oct 13 14:12 old 1291 (:0)
Where and why would the time format change only in a bash script and
only on two machines.
Background is these are public computers and I have have script that
reset the profiles every night. The rest script ends any active profile
sessions before restoring them. It calls the killuser script that finds
the pids of the active sessions and kill them:
PIDS=$(who -u | egrep "${USERSLIST}" | tr -s ' ' | cut -d ' ' -f 6)
The script takes a list of uids and builds a regex ORed list
"foo|bar|baz", removes the duplicated spaces and grabs the 6th field
which should be the pid. So $PIDS should be an array of all active
'guest' sessions. And it does on all but two systems where the who
command looks like the former format with the date '2011-10-13 14:12'
but fails where the date format is 'Oct 13 14:12'. The latter end up
getting the IDLE field and not the PID field.
1) Why would the format be different in the bash script from the command
line?
2) Where would the setting be? .profile is the same for system that work
vs ones that don't
3) If there is a better way to get the pids of selected active user
sessions, I am open to suggestions.
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Written by "Jonathan N. Little"
19/10/2011 9.22.29
Check some pics on this site!
23/05/2012 5.28.43