Search code examples
pythonpython-3.xubuntu-14.04zenity

Adding pipe symbol in Python command


I am trying to write a script to copy files from one flash drive to another using Python along with Zenity UI. Variables Sorz_star and Desz contains path to two flash drives.

subprocess.call('cp -R %s %s |zenity --progress --text "Copying" --pulsate --auto-close'%(Sorz_star,Desz), shell=True)

This works fine in terminal but when I use this command in my copy.py file it shows this error

sh: 2: Syntax error: "|" unexpected

Solution

  • One or both of the substituted variables probably ends with a newline. Use .strip() on them to remove it.