[Tutor] subprocess check_output

Derek Smith DerekSmith at racksquared.com
Wed Sep 20 17:09:39 EDT 2017


Why does python output this b and newline characters and how can I may it return just what I need, the number 8 w/no special characters? See below. I tried str(scratch), but no go, still prints that garbage.


#!/bin/env python3

cmdstr    = "/usr/bin/dsmadmc"
id              = "-id=dereksmith"
pw           = "-password=xxxx"
do            = "-dataonly=yes"


from subprocess import check_output
scratch = check_output( [ cmdstr, id, pw, do, "select", "count(*)", "from", "libvolumes", "where", "status='Scratch'", "and", "library_name='TS3200'" ] )
print (scratch)

__OUTPUT__
# ./ts3200_scratchcount_check.py
email sent successfully
b'           8\n'


Thx!!
Derek Smith  |  Unix/TSM Administrator  | Racksquared Data Centers
::  dereksmith at racksquared.com  *: www.racksquared.com<http://www.racksquared.com/> |  www.racksquared.jobs<http://www.racksquared.jobs/>

[cid:image003.png at 01D2E9AA.1B9CF8F0]



More information about the Tutor mailing list