On Wed, 19 Jan 2022 19:16:19 -0800 (PST), James Smith
<bjlockie...@gmail.com> declaimed the following:

>I'm trying to run a shell command but the stdout is empty:
>
>import subprocess
>
>torrentno=8
>cmd="/usr/bin/transmission-remote --torrent %s --info", str(torrentno)

        Don't you need to provide for that %s? Perhaps

cmd="/usr/bin/transmission-remote --torrent %s --info" % torrentno

As coded, you are passing a TUPLE of two strings as cmd (fyi: the %s will
take the string representation of whatever is the matching argument on the
right, so str() isn't needed -- and if you need a number for both --torrent
and --info you'll need another %s, and (torrentno, torrentno) on the right)

>res=subprocess.run(cmd, shell=True, check=True, universal_newlines=True, 
>capture_output=True)
>print(res)
>
>CompletedProcess(args=('/usr/bin/transmission-remote --torrent %s --info', 
>'1'), returncode=0, stdout='', stderr='')


-- 
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to