[Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

Mats Wichmann mats at wichmann.us
Wed Nov 7 18:30:29 EST 2018


On 11/7/18 4:31 AM, srinivasan wrote:
> Even after changing as per the below
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> 
> Still my output is:
> */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> 
> My expected output should be only:
> *vfat*

then you don't want -f3...
vfat is the 4th field if you split (cut) that string on equal signs.

usually if a shell pipeline doesn't work from Python, it means you're
not invoking the shell.  I notice in your original code you default the
"shell=" value to false.



More information about the Tutor mailing list