[Tutor] need help writing subprocess output to file(s)

Eryk Sun eryksun at gmail.com
Mon Apr 27 15:49:18 EDT 2020


On 4/26/20, Cameron Simpson <cs at cskk.id.au> wrote:
>
> Something like this:
>
>     for ip in ips:
>         with open(op + '.out', 'w') as output:
>             output = subprocess.Popen(["/opt/bin/sdptool", ip, "check"],
> stdout=output)

Typo: "op" -> "ip".

I'd replace dots and colons (IPv6) with underscores. In particular,
using colon in a filename is problematic if the file ever needs to be
accessed in Windows. Colon is reserved by most Windows filesystems,
and it's used by NTFS to name file streams (e.g.
"filename:streamname:$DATA" and "dirname:$I30:$INDEX_ALLOCATION") [1].

[1]: https://docs.microsoft.com/en-us/windows/win32/fileio/file-streams


More information about the Tutor mailing list