Invoking External Programs

In this article, you will learn how to execute an external application - for example, run a command line, execute scripts, or interact with the operating system.

The behaviour and syntax will differ a little depending on your operating system — Windows/Linux/macOS. The examples documented here are on a Windows machine.

Using os.execute() allows you to execute external programs. This code snippet shows some of the syntax you can use:

Screen Shot 2024-09-30 at 11.25.46 AM.png

io.popen() is helpful in that it allows you to open a command line process and read and write to it. This shows an example of reading into a directory using a command:

Screen Shot 2024-09-30 at 11.37.53 AM.png

For more details, see io.popen().