Greetings,
I DON'T actually need a response since I have a solution but the education would be nice.
Some history:
We've recently converted from alpha login ID's in the LDAP world to something called workday ID's(not my idea!). What this meant for us Linux admins was we had change everyone's alpha ID they'd used for years to a numeric ID. Not a big deal with the exception of a particular command we use to list jobs on the cluster. If I execute:
bjobs -u all -m C7CRA
I now get the following:
JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME
452790 257738 RUN crash_para t70cra110 16*t70c7n22 *art_ODB_5 Nov 27 10:00
16*t70c7n222
16*t70c7n223
16*t70c7n224
16*t70c7n227
16*t70c7n226
16*t70c7n228
16*t70c7n225
452803 257738 RUN crash_para t70cra110 16*t70c7n22 *L_Corr_03 Nov 27 10:55
16*t70c7n230
16*t70c7n231
16*t70c7n234
16*t70c7n236
16*t70c7n233
16*t70c7n232
16*t70c7n235
452878 257738 RUN crash_para t70cra110 16*t70c7n25 *L_Corr_04 Nov 27 17:01
16*t70c7n261
16*t70c7n262
16*t70c7n263
16*t70c7n264
16*t70c7n258
16*t70c7n260
16*t70c7n259
The second field of the job ID line is the user's name now and we have been using ypcat to figure out who's who. A real pain, so I wrote a script (bjobs.sh) to replace the workday numeric ID with the 5th field from the ypcat passwd output.
Script:
#!/bin/bash
echo "JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME"
for JOBID in `bjobs $* | grep RUN | awk '{print $1}'`
do
USERID=`bjobs ${JOBID} | grep RUN | awk '{print $2}'`
USERNAME=`ypcat passwd | grep ${USERID} | cut -d: -f5`
bjobs ${JOBID} | grep -v STAT | sed "s/${USERID}/${USERNAME}/"
done
Executed as:
bjobs.sh -u all -m C76CRA
While this works just fine I though I'd put this up here to see if anyone had a better way of doing this. Maybe a one line "bjobs -u all -m C7CRA" with awk and/or sed to grab that second field of the jobid line and replace it as the script does using the variable it gets from the ypcat passwd output. I tried various methods, got frustrated and simply went with what I knew would work. Thanks in advance for anyone willing to chime in.