Linked Questions

Popular Questions

Formatting output values in Table form

Asked by At

I have problem with my code, so please anyone can help me?

b'Filesystem'
b'Size'
b'Used'
b'Avail'
b'Use%'
b'Mounted'
b'on'
b'/dev/mapper/rhel-root
b'17G'
b'7.7G'
b'9.4G'
b'46%'
b'/'
b'devtmpfs'
b'15G'
b'0'
b'15G'
b'0%'

And i want that my code look like this:

Filesystem                             Size  Used Avail Use% Mounted on
/dev/abd/abd                   10G   93M   10G   1% /
devtmpfs                                63G     0   63G   0% /dev
tmpfs                                   63G     0   63G   0% /dev/shm
tmpfs                                   63G  553M   63G   1% /run
tmpfs                                   63G     0   63G   0% /sys/fs/cgroup
/dev/mapper/rhel-usr                    10G  1.2G  8.9G  12% /usr
/dev/vda1                             1014M  139M  876M  14% /boot
/dev/mapper/xxx-xxx                   10G  158M  9.9G   2% /home
/dev/mapper/rhel-tmp                   5.0G   33M  5.0G   1% /tmp
/dev/mapper/rhel-var                    10G  570M  9.5G   6% /var
/dev/mapper/vg--prd-lv--prd            2.0T  1.8T  256G  88% /abcd
/dev/mapper/xxxxxxxxxxxxxxxxxxxxxxxx   50G  2.3G   48G   5% /usr/openv
tmpfs                                   13G     0   13G   0% /run/user/0
tmpfs                                   13G     0   13G   0% /run/user/1001

=================================================================
I am using paramiko to connect to the server, but the output is like list so i want like this:

stdin, stdout, stderr =ssh.exec_command('df -h')
outp=stdout.read()
data=[outp]

for col in data[0].split():
print(col)

Related Questions