O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running shell scripts

We generally collect a set of commands used in performing an operation in a file, called a shell script in the Unix world and batch file in Windows. The commands present in these files are executed sequentially, with the exceptions being when you have conditional blocks or loops in the scripts. 

These shell scripts are evaluated by the shell in which they get executed. Different types of shells available are bash, csh, ksh, and so on. The bash shell is the most commonly used shell.

In this recipe, we will write a simple shell script and then invoke the same from the Java code using the ProcessBuilder and Process objects.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required