Basic python question
Thanks Aldwin that helps but it looks like it is reversing the numbers
for some reason:
the df command returns the following:
I used your example and did:
x,y = set(output.split())
My assumption would be that x should be 7 and y should be 2. However,
when I print x and y it seems to be reversed (x is 2 and y is 7). Am
I missing something?
On Wed, Oct 2, 2019 at 8:49 PM Aldwin Pollefeyt
<aldwinaldwindev at gmail.com> wrote:
> You could use:
> >>> x, y = set(output.split())
> On Thu, Oct 3, 2019 at 11:44 AM Jagga Soorma <jagga13 at gmail.com> wrote:
>> I am new to python and trying to do some basic things with python. I
>> am writing a script that runs a df command and I need parts of that
>> output saved in 2 different variables. Is this something that can be
>> done? I can do this by running multiple df commands but would prefer
>> to make only one call:
>> inode_cmd = "/bin/df --output=pcent,ipcent /var| grep -v Use | tr '%' ' '"
>> output = subprocess.check_output( inode_cmd,
>> stderr=subprocess.STDOUT, shell=True )
>> But this would end up giving me the following:
>> #df --output=pcent,ipcent /var | grep -v Use | tr '%' ' '
>> 5 1
>> I would like variable x to be 5 and variable y to be 1. Is there a
>> easier way to do this?
>> Thanks in advance for your guidance.