I am trying to do the following command (to download Calibre through a python script):
sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
Following some of the answers on here on how to PIPE, I have been doing this:
import subprocess
from subprocess import Popen, PIPE
wget = subprocess.Popen(["sudo -v wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py"], stdout=PIPE)
run = subprocess.Popen(["sudo python -c "import sys; exec(sys.stdin.read()); main()""], stdin=wget.stdout)
I have tried changing many things but NOTHING is working. There are too many errors to put here. Can anyone correct this? Many thanks in advance.
All I get is the first
SyntaxErrors (quotes usage). You should fix them before posting a question. ThePopen()usage in your code is also incorrect: at the very least you should read the description of the first parameterargsthat specifies the command to run. Is the phrase "a sequence of program arguments" not sufficiently clear? Why do you callPopen(["cmd arg1 arg2"])instead ofPopen(["cmd", "arg1", "arg2"])?