#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2010 <NAME>.  All rights reserved.
#
"""
Capture the output of a command and test its
exit code at the same time.
"""

#end_pymotw_header
import subprocess

completed = subprocess.run(
    ['ls', '-1'],
    stdout=subprocess.PIPE,
)
print('returncode:', completed.returncode)
print('Have {} bytes in stdout:\n{}'.format(
    len(completed.stdout),
    completed.stdout.decode('utf-8'))
)

#!/usr/bin/env python3
# encoding: utf-8
#
# Copyright (c) 2010 <NAME>.  All rights reserved.
#
"""
Capture the output of a command and test its
exit code at the same time.
"""

#end_pymotw_header
import subprocess

completed = subprocess.run(
    ['ls', '-1'],
    stdout=subprocess.PIPE,
)
print('returncode:', completed.returncode)
print('Have {} bytes in stdout:\n{}'.format(
    len(completed.stdout),
    completed.stdout.decode('utf-8'))
)

#!/usr/bin/env python3 # encoding: utf-8 # # Copyright (c) 2010 <NAME>.  All rights reserved. # Capture the output of a command and test its exit code at the same time. #end_pymotw_header