September 2015
Intermediate to advanced
250 pages
6h 40m
English
Most operating systems support the shebang syntax to run arbitrary scripts. We can use that approach to run stand-alone files with Scala code in it. This eliminates the needs to explicitly invoke the scala command and works seamlessly as long as Scala is installed on the system.
On Unix-like systems, set the shebang preamble in the script like this:
| FirstStep/hello.sh | |
| | #!/usr/bin/env scala |
| | println("Hello " + args(0)) |
Make sure the file hello.sh has executable permission by typing chmod +x hello.sh. Then to run it, type the following command on the command line:
| | ./hello.sh Buddy |
Buddy is the argument that is passed to the script. Here’s the output ...
Read now
Unlock full access