Different Output when Piping TSM Result

LuXor

Active Newcomer
Joined
Jan 15, 2018
Messages
6
Reaction score
0
Points
0
PREDATAR Control23

I am writing a script to give me the output of the TSM 'events' table, showing the error code for when a backup failure occurs. I have written a script which, when launched from the AIX terminal, runs:

dsmadmc -se=$tsm_server -id=$var_userid -password=$var_pswd "SELECT node_name,actual_start,completed,status,result,reason FROM events WHERE node_name='$var_client' AND scheduled_start> '$var_date 00:00:00' AND status!='Future'"

When I run this script, the resulting output gives me the login header info about the TSM version, IBM copyright info, etc, and then my result. I want to remove all of this and just see the result for the client being backed up.

I have tried piping the result into various unix tools, such as 'tail -n +10', grep -vE "{ANS error message}", etc, but no matter which one I use, I get a garbled result, as per the second screenshot.


I have other SELECT queries in my script, which I have been able to successfully cut out extraneous information without affecting the result:

dsmadmc -se=$tsm_server -id=$var_userid -password=$var_pswd "SELECT nodename,date_time,message FROM actlog WHERE nodename='$var_client' AND severity='E' AND date_time> '$var_date 00:00:00' ORDER BY date_time" | tail -n +10

Both queries appear to be the same to me yet I am getting vastly different results when piping them into 'tail' or 'grep', in order to clean up the result. Does anyone know why this is and what can be done to get the desired result?


normal output without piping.png

garbled output once piped to grep.png
 
PREDATAR Control23

I always found doing a -tab -dataonly=yes is beneficial when using grep or other tools.
Example basic script.
Code:
#!/bin/ksh
#Global Variables
TSMADMIN=<admin>
TSMSE=<server here>
TSMPA=<the admin password>

# Function to call tivoli!
tsmcmd() {
    dsmadmc -se=${TSMSE} -id=${TSMADMIN} -pa=${TSMPA} -tab -dataonly=yes "$*"
}


    tsmcmd "select node_name,actual_start,completed,status,result,reason FROM events WHERE node_name='<node_name>'"
What is sent to screen:
Code:
<node_name> 2017-11-16 21:00:22.000000      2017-11-17 01:58:26.000000      Completed       0       All operations completed successfully.
<node_name> 2017-11-17 21:00:26.000000      2017-11-18 01:35:16.000000      Completed       0       All operations completed successfully.
 
Top