Sign inSign up free

1454. Run Commands Safely From Python

medium 20 XP ~12 minHands-on lab Pro

/home/student/tools/compress.py FILE... gzips each file it's given (keeping the original). It was written with os.system, and three things go wrong: names with spaces fail, a file name with a ; in it runs another command, and it always exits 0, even when gzip failed.

This is a Pro problem

Pro unlocks every lab and quiz, all roadmaps and a full daily plan.

Unlock with Pro

Part of Python for DevOps. Next step: Scan a Repository for Leaked Secrets

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Pro lab

Upgrade to open a machine for this problem.

See Pro