Skip to content
← Back to Community
os.system Python 3
Profile icon
DeBeast591

I have a project on GitHub called PyDOS (https://www.github.com/DeBeast591/PyDOS/) and I have used os.system() multiple times. I know that os.system() can be dangerous and I want to use an alternitive to it. If there are any functions/modules that do these functions but their safe then please tell me. The commands that I need are rm -rf (for removing files/folders), mkdir (for making folders), clear, nano (for file editing), etc.

Thanks in advance.

Voters
Profile icon
LOST74K
Profile icon
DeBeast591
Comments
hotnewtop
Profile icon
[deleted]

From what I see, you shoudnt worry. Also, why is it dangerous?

Profile icon
DeBeast591

@TaylorLiang if someone were to name a file "; rm -rf /" with root ability then it can delete ALL files and folders. This can make my program dangerous.

Profile icon
[deleted]

@DeBeast591 That shoudnt do anything, as python sanitizes strings, so you dont have to be concerned

Profile icon
DeBeast591

@TaylorLiang what do you mean by Python sanitizing strings? Does it check them before executing a script with them?

Profile icon
[deleted]

@DeBeast591 Yes. Image PHP santized input, python auto does that

Profile icon
DeBeast591

@TaylorLiang cool, ill test that (because i'm still confused on its limits) and go from there. Thanks for the help!