Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fuser -u script 1

Status
Not open for further replies.

jpor

Technical User
Nov 29, 2000
212
GB
Hi all,

I am currently putting a ksh script together that allows the standard user to see who is currently in a Database table. At the moment I have the following put together:

clear

trap "" 1 2 3

until [ -n "$validchoice" ]
do
#
# Menu
#
echo '

Check whos on before closing down

1. I am closing off Sales Ledger

2. I am closing off Nominal/General Ledger

3. I am closing off Stock

4. I am closing off Purchase Ledger

Q. Quit/Exit

Please select one of the above (1-4 or Q) : \c'

#
# Read and Process Selection
#

read choice
echo

case "$choice"
in

1) clear
## mong=`fuser -u /usr/cs3/sysmprc/sl* | awk -F: '{print$3}'`
mong=`fuser -u /usr/cs3/sysmprc/sl*`
echo $mong | awk -F: '{print$3}'
validchoice=TRUE;;
2) clear
fuser -u /usr/cs3/sysmprc/nl* | awk '{print$3}'
validchoice=TRUE;;
3) clear
fuser -u /usr/cs3/sysmprc/st* | awk '{print$3}'
validchoice=TRUE;;
4) clear
fuser -u /usr/cs3/sysmprc/pl* | awk '{print$3}'
validchoice=TRUE;;
Q) clear
trap 1 2 3
exit;;
q) clear
trap 1 2 3
exit;;

*) echo "\n\nTry reading the options ";;
esac
done

This works fine. Except I need to get just the usernames against each table. Look this up against the /etc/passwd and bring back to the screen the usernames 'realname'.

Any Ideas?

Thanks in advance.

( "To become Wise, first you must ask Questions")
 
Okay pastde your revised script in place:

fuser -u /usr/cs3/sysmprc/sl* | awk -F: '
BEGIN{while(getline<"/etc/passwd">0)a[$1]=$5}
/\(/{n=split($2,u,"(")
for(i=2;i<=n;++i){
sub(/\).*/,"",u);print $1,u,a[u]
} }'

Ran it and get this:

Please Wait! Getting Usernames

/usr/cs3/sysmprc/sl.out:
/usr/cs3/sysmprc/sl.sql:
/usr/cs3/sysmprc/slanalm.dat:
/usr/cs3/sysmprc/slanalm.idx:
/usr/cs3/sysmprc/slbankm.dat:
/usr/cs3/sysmprc/slbankm.idx:
/usr/cs3/sysmprc/slbataudm.dat:
/usr/cs3/sysmprc/slbataudm.idx:
/usr/cs3/sysmprc/slcadvm.dat:
/usr/cs3/sysmprc/slcadvm.idx:
/usr/cs3/sysmprc/slcasham.dat:
/usr/cs3/sysmprc/slcasham.idx:
/usr/cs3/sysmprc/slcashbm.dat:
/usr/cs3/sysmprc/slcashbm.idx:
/usr/cs3/sysmprc/slcashdm.dat:
/usr/cs3/sysmprc/slcashdm.idx:
/usr/cs3/sysmprc/slcashem.dat:
/usr/cs3/sysmprc/slcashem.idx:
/usr/cs3/sysmprc/slcashm.dat: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slcashm.idx: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slcashmcm.dat:
/usr/cs3/sysmprc/slcashmcm.idx:
/usr/cs3/sysmprc/slcashptm.dat:
/usr/cs3/sysmprc/slcashptm.idx:
/usr/cs3/sysmprc/slcashwm.dat:
/usr/cs3/sysmprc/slcashwm.idx:
/usr/cs3/sysmprc/slccnvdm.dat:
/usr/cs3/sysmprc/slccnvdm.idx:
/usr/cs3/sysmprc/slcontm.dat:
/usr/cs3/sysmprc/slcontm.idx:
/usr/cs3/sysmprc/slctaxm.dat:
/usr/cs3/sysmprc/slctaxm.idx:
/usr/cs3/sysmprc/slctxtm.dat:
/usr/cs3/sysmprc/slctxtm.idx:
/usr/cs3/sysmprc/slcurrm.dat:
/usr/cs3/sysmprc/slcurrm.idx:
/usr/cs3/sysmprc/slcustam.dat:
/usr/cs3/sysmprc/slcustam.idx:
/usr/cs3/sysmprc/slcustcm.dat:
/usr/cs3/sysmprc/slcustcm.idx:
/usr/cs3/sysmprc/slcustem.dat: (unit5azh)(ccsrvjxe)(ccsrvlzs)(ccsrvaxa)(unit5azh)
/usr/cs3/sysmprc/slcustem.idx: (unit5azh)(ccsrvjxe)(ccsrvlzs)(ccsrvaxa)(unit5azh)
/usr/cs3/sysmprc/slcusteum.dat:
/usr/cs3/sysmprc/slcusteum.idx:
/usr/cs3/sysmprc/slcustgm.dat:
/usr/cs3/sysmprc/slcustgm.idx:
/usr/cs3/sysmprc/slcusthlm.dat:
/usr/cs3/sysmprc/slcusthlm.idx:
/usr/cs3/sysmprc/slcusthm.dat:
/usr/cs3/sysmprc/slcusthm.idx:
/usr/cs3/sysmprc/slcusthsm.dat:
/usr/cs3/sysmprc/slcusthsm.idx:
/usr/cs3/sysmprc/slcustim.dat:
/usr/cs3/sysmprc/slcustim.idx:
/usr/cs3/sysmprc/slcustlm.dat:
/usr/cs3/sysmprc/slcustlm.idx:
/usr/cs3/sysmprc/slcustlocm.dat:
/usr/cs3/sysmprc/slcustlocm.idx:
/usr/cs3/sysmprc/slcustm.dat: (unit5dzy)(unit5azh)(unit5sjh)(unit5azw)(unit5nzb)
/usr/cs3/sysmprc/slcustm.idx: (unit5dzy)(unit5azh)(unit5sjh)(unit5azw)(unit5nzb)
/usr/cs3/sysmprc/slcustom.dat:
/usr/cs3/sysmprc/slcustom.idx:
/usr/cs3/sysmprc/slcustpm.dat:
/usr/cs3/sysmprc/slcustpm.idx:
/usr/cs3/sysmprc/slcusttm.dat:
/usr/cs3/sysmprc/slcusttm.idx:
/usr/cs3/sysmprc/slddebm.dat:
/usr/cs3/sysmprc/slddebm.idx:
/usr/cs3/sysmprc/slintdm.dat:
/usr/cs3/sysmprc/slintdm.idx:
/usr/cs3/sysmprc/slinthem.dat:
/usr/cs3/sysmprc/slinthem.idx:
/usr/cs3/sysmprc/slinthm.dat:
/usr/cs3/sysmprc/slinthm.idx:
/usr/cs3/sysmprc/slinvagm.dat:
/usr/cs3/sysmprc/slinvagm.idx:
/usr/cs3/sysmprc/slinvam.dat:
/usr/cs3/sysmprc/slinvam.idx:
/usr/cs3/sysmprc/slinvcm.dat:
/usr/cs3/sysmprc/slinvcm.idx:
/usr/cs3/sysmprc/slinvdem.dat:
/usr/cs3/sysmprc/slinvdem.idx:
/usr/cs3/sysmprc/slinvem.dat:
/usr/cs3/sysmprc/slinvem.idx:
/usr/cs3/sysmprc/slinvfam.dat:
/usr/cs3/sysmprc/slinvfam.idx:
/usr/cs3/sysmprc/slinvgm.dat:
/usr/cs3/sysmprc/slinvgm.idx:
/usr/cs3/sysmprc/slinvhem.dat:
/usr/cs3/sysmprc/slinvhem.idx:
/usr/cs3/sysmprc/slinvim.dat:
/usr/cs3/sysmprc/slinvim.idx:
/usr/cs3/sysmprc/slinvm.dat: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slinvm.idx: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slinvvcm.dat:
/usr/cs3/sysmprc/slinvvcm.idx:
/usr/cs3/sysmprc/slinvxm.dat: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slinvxm.idx: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slitemam.dat:
/usr/cs3/sysmprc/slitemam.idx:
/usr/cs3/sysmprc/slitemcm.dat:
/usr/cs3/sysmprc/slitemcm.idx:
/usr/cs3/sysmprc/slitemem.dat:
/usr/cs3/sysmprc/slitemem.idx:
/usr/cs3/sysmprc/slitemgm.dat:
/usr/cs3/sysmprc/slitemgm.idx:
/usr/cs3/sysmprc/slitemim.dat:
/usr/cs3/sysmprc/slitemim.idx:
/usr/cs3/sysmprc/slitemm.dat: (ccsrvrvs)(unit5dzy)(unit5sjh)(unit5azw)(unit5nzb)
/usr/cs3/sysmprc/slitemm.idx: (ccsrvrvs)(unit5dzy)(unit5sjh)(unit5azw)(unit5nzb)
/usr/cs3/sysmprc/slitemmcm.dat:
/usr/cs3/sysmprc/slitemmcm.idx:
/usr/cs3/sysmprc/sljrnm.dat: (ccsrvrvs)(unit5sjh)(unit5azw)
/usr/cs3/sysmprc/sljrnm.idx: (ccsrvrvs)(unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slletaudm.dat:
/usr/cs3/sysmprc/slletaudm.idx:
/usr/cs3/sysmprc/sllettm.dat:
/usr/cs3/sysmprc/sllettm.idx:
/usr/cs3/sysmprc/sln07598.T09:
/usr/cs3/sysmprc/sln10586.T06:
/usr/cs3/sysmprc/sln54526.T05:
/usr/cs3/sysmprc/sln61008.T08:
/usr/cs3/sysmprc/sln73902.T03:
/usr/cs3/sysmprc/sln85328.T09:
/usr/cs3/sysmprc/slpaymm.dat:
/usr/cs3/sysmprc/slpaymm.idx:
/usr/cs3/sysmprc/slpaytm.dat:
/usr/cs3/sysmprc/slpaytm.idx:
/usr/cs3/sysmprc/slrdlstm.dat:
/usr/cs3/sysmprc/slrdlstm.idx:
/usr/cs3/sysmprc/slrefdem.dat:
/usr/cs3/sysmprc/slrefdem.idx:
/usr/cs3/sysmprc/slrefdm.dat: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slrefdm.idx: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slrefdmcm.dat:
/usr/cs3/sysmprc/slrefdmcm.idx:
/usr/cs3/sysmprc/slremhm.dat:
/usr/cs3/sysmprc/slremhm.idx:
/usr/cs3/sysmprc/slremm.dat:
/usr/cs3/sysmprc/slremm.idx:
/usr/cs3/sysmprc/slrhlstm.dat:
/usr/cs3/sysmprc/slrhlstm.idx:
/usr/cs3/sysmprc/slsupsm.dat:
/usr/cs3/sysmprc/slsupsm.idx:
/usr/cs3/sysmprc/sltextm.dat:
/usr/cs3/sysmprc/sltextm.idx:
/usr/cs3/sysmprc/slvlexm.dat:
/usr/cs3/sysmprc/slvlexm.idx:
/usr/cs3/sysmprc/slxrefm.dat: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slxrefm.idx: (unit5sjh)(unit5azw)
/usr/cs3/sysmprc/slxrefmcm.dat:
/usr/cs3/sysmprc/slxrefmcm.idx:
/usr/cs3/sysmprc/slxrefrm.dat:
/usr/cs3/sysmprc/slxrefrm.idx:

But nothing else.
How can I check my version of awk?

Or is ti worth downloading gawk?

( &quot;To become Wise, first you must ask Questions&quot;)
 
Okay downloaded gawk version 3.0.5 from the bull freeware website and have installed this on the live box with AIX 4.3.3 ML9. Tried both scripts with gawk but still get the same output.

Anyone else have any ideas?


( &quot;To become Wise, first you must ask Questions&quot;)
 
Just a though, replace this:
fuser -u /usr/cs3/sysmprc/sl* | awk -F: '
By this:
fuser -u /usr/cs3/sysmprc/sl* 2>&1 | awk -F: '

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

This is the output I now get from the change:

/usr/cs3/sysmprc/slcashm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slcashm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slcustem.dat ccsrvajc Amanda Clarke, Finance
/usr/cs3/sysmprc/slcustem.dat ccsrvpxp Pauline Parker, Spares
/usr/cs3/sysmprc/slcustem.dat ccsrvjxe Jason Emmerson, Spares
/usr/cs3/sysmprc/slcustem.idx ccsrvajc Amanda Clarke, Finance
/usr/cs3/sysmprc/slcustem.idx ccsrvpxp Pauline Parker, Spares
/usr/cs3/sysmprc/slcustem.idx ccsrvjxe Jason Emmerson, Spares
/usr/cs3/sysmprc/slcustm.dat unit5dzy Darren Yates, Credit Control
/usr/cs3/sysmprc/slcustm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slcustm.dat unit5nzb Nicola Brettle,Claims/Invoicing Unit5
/usr/cs3/sysmprc/slcustm.idx unit5dzy Darren Yates, Credit Control
/usr/cs3/sysmprc/slcustm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slcustm.idx unit5nzb Nicola Brettle,Claims/Invoicing Unit5
/usr/cs3/sysmprc/slinvm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slinvm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slinvxm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slinvxm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slitemm.dat ccsrvrvs Rachel Simon, Finance
/usr/cs3/sysmprc/slitemm.dat unit5dzy Darren Yates, Credit Control
/usr/cs3/sysmprc/slitemm.dat unit5azw Alan West,Credit Control
/usr/cs3/sysmprc/slitemm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slitemm.dat unit5nzb Nicola Brettle,Claims/Invoicing Unit5
/usr/cs3/sysmprc/slitemm.idx ccsrvrvs Rachel Simon, Finance
/usr/cs3/sysmprc/slitemm.idx unit5dzy Darren Yates, Credit Control
/usr/cs3/sysmprc/slitemm.idx unit5azw Alan West,Credit Control
/usr/cs3/sysmprc/slitemm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slitemm.idx unit5nzb Nicola Brettle,Claims/Invoicing Unit5
/usr/cs3/sysmprc/sljrnm.dat ccsrvrvs Rachel Simon, Finance
/usr/cs3/sysmprc/sljrnm.dat unit5azw Alan West,Credit Control
/usr/cs3/sysmprc/sljrnm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/sljrnm.idx ccsrvrvs Rachel Simon, Finance
/usr/cs3/sysmprc/sljrnm.idx unit5azw Alan West,Credit Control
/usr/cs3/sysmprc/sljrnm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slrefdm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slrefdm.idx unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slxrefm.dat unit5sjh Simon Holland,Credit control
/usr/cs3/sysmprc/slxrefm.idx unit5sjh Simon Holland,Credit control

In other words. It now works. Many Thanks fro your patience.


( &quot;To become Wise, first you must ask Questions&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top