Skip to main content

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.

1. os.execute() to execute external programs

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

2. io.popen() opens a command line process

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:

For more details, see io.popen().