operating system

Scala - An index of methods to run/execute external system commands

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.20, “An index of methods available to run external system commands.”

The following tables list the methods of the scala.sys.process package that you can use when running external (system) commands.

Methods to execute external commands

Table 12-1 lists the methods that you can use to execute system commands.

Table 12-1. Methods to execute system commands

Scala: How to run an external command (process) in a different directory alvin June 19, 2015 - 11:26am

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a very short recipe, Recipe 12.18, “How to run an external command (process) in a different directory.”

Problem

You want to use another directory as the base directory when running an external command.

Scala: How to handle the STDOUT and STDERR of external commands alvin June 19, 2015 - 11:20am

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.13, “How to handle the STDOUT and STDERR of external commands.”

Problem

You want to run an external command and get access to both its STDOUT and STDERR.

Solution

The simplest way to do this is to run your commands as shown in previous recipes, and then capture the output with a ProcessLogger. This Scala shell script demonstrates the approach:

How to execute external commands and use their STDOUT in Scala alvin June 19, 2015 - 11:18am

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.12, “How to execute external commands and use their STDOUT in Scala.”

Back to top

Problem

You want to run an external command and then use the standard output (STDOUT) from that process in your Scala program.

Back to top

Solution

Use the !! method to execute the command and get the standard output from the resulting process as a String.

Table of Contents

  1. Problem
  2. Solution
Back to top
Website visitors by Operating System and Browser alvin August 31, 2013 - 6:18pm

Here’s a quick look at recent visitors to this website, first by Operating System and then by Browser.

Getting global keystrokes in a Java or Scala Swing application alvin June 14, 2013 - 10:11am

If you ever wanted to get access to global operating system keystrokes from a Java or Scala Swing application, you can do it with the jnativehook library. Here’s a short demo:

Here’s the full Scala source code for the demo. I put a few comments in the code to highlight the important areas:

The Google Chrome OS alvin July 8, 2009 - 7:53am

Wow, last night Google announced a new project named the "Google Chrome Operating System" -- and it's not April 1st. Here's a brief blurb from their blog post:

A better test for detecting Unix operating systems in an Ant build script alvin July 5, 2009 - 7:08pm

In several previous tutorials (see my references below) about testing for operating systems within Ant build scripts, and then conditionally executing targets based on the results of those tests, I noted that Mac OS X operating systems respond to both Mac and Unix test conditions based on the Ant "os family" test. I mentioned that I thought this behavior was probably correct, because Mac OS X is built an a Unix base (BSD, to be specific).

Ant FAQ: How to determine the platform operating system in an Ant build script

Problem

You're creating an Ant build script, and you need to determine the operating system the script is running on, so you can make conditional decisions within the build script. You typically want/need to do this if you're going to run tasks/targets that are different for each operating system (Mac, Windows, Unix, etc.).