Skip to content
Advertisement

Capture output from external command and write it to a file

I am trying to create a script that calls on a linux command from my Ubuntu server and prints the output of aforementioned command to txt files. This is literally the first script I’ve ever written, I just started learning python recently. I want 3 files in 3 separate folders with filenames unique to date.

JavaScript

It is failing at the f.write() functions. I’m stuck at making the output of the linux commands the actual text in the new files.

Advertisement

Answer

I figured it out after all. The following works great!

JavaScript
Advertisement