This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scripting with Scala

4 replies
Andrey Popp
Joined: 2010-07-20,
User offline. Last seen 42 years 45 weeks ago.

Hello,

wouldn't be great to have an easy way to run Scala scripts
from command line:

$ runscala MyScript.scala

Haskell GHC already do this with runghc executable.

Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: Scripting with Scala

On Tue, Feb 15, 2011 at 2:44 PM, Andrey Popp <8mayday [at] gmail [dot] com> wrote:
> wouldn't be great to have an easy way to run Scala scripts
> from command line:
>
>  $ runscala MyScript.scala
>
> Haskell GHC already do this with runghc executable.

$ scala MyScript.scala
$ scala -e 'println("Hello, World!")'

Or even:

$ alias runscala=scala # ;P

-jason

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Scripting with Scala
Almost there... The correct syntax is:
    $ scala MyScript.scala
Or from the *nix command line you can simply prefix your script with:
    #!/bin/sh     exec scala "$0" "$@"    !#
mark as executable, and run it as
    $ ./MyScript.scala
as per any other bash/awk/perl/eeeeeeeeeetc. script
On 15 February 2011 13:44, Andrey Popp <8mayday [at] gmail [dot] com> wrote:
Hello,

wouldn't be great to have an easy way to run Scala scripts
from command line:

 $ runscala MyScript.scala

Haskell GHC already do this with runghc executable.



--
Kevin Wright

gtalk / msn : kev [dot] lee [dot] wright [at] gmail [dot] comkev [dot] lee [dot] wright [at] gmail [dot] commail: kevin [dot] wright [at] scalatechnology [dot] com
vibe / skype: kev.lee.wrightquora: http://www.quora.com/Kevin-Wright
twitter: @thecoda

"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Scripting with Scala
On Tue, Feb 15, 2011 at 11:44, Andrey Popp <8mayday [at] gmail [dot] com> wrote:
Hello,

wouldn't be great to have an easy way to run Scala scripts
from command line:

 $ runscala MyScript.scala

Haskell GHC already do this with runghc executable.

What's wrong with the command below?

$ scala MyScript.scala

--
Daniel C. Sobral

I travel to the future all the time.
Razvan Cojocaru 3
Joined: 2010-07-28,
User offline. Last seen 42 years 45 weeks ago.
RE: Scripting with Scala

Guess what - it works even without having scala installed, like from a
cellphone, eh?

Checkout http://www.simplyscala.com/ for a REPL version or
http://www.tryscala.org/ for a script-pad version.

Or even over IRC or telnet (telnet www.tryscala.org 4445)

... these scripts won't affect the local state but good for the usual
typefoolery type guessing game :)

Cheers

-----Original Message-----
From: scala-debate [at] googlegroups [dot] com [mailto:scala-debate [at] googlegroups [dot] com]
On Behalf Of Jason Zaugg
Sent: February-15-11 8:50 AM
To: Andrey Popp
Cc: scala-debate
Subject: Re: [scala-debate] Scripting with Scala

On Tue, Feb 15, 2011 at 2:44 PM, Andrey Popp <8mayday [at] gmail [dot] com> wrote:
> wouldn't be great to have an easy way to run Scala scripts from
> command line:
>
>  $ runscala MyScript.scala
>
> Haskell GHC already do this with runghc executable.

$ scala MyScript.scala
$ scala -e 'println("Hello, World!")'

Or even:

$ alias runscala=scala # ;P

-jason

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland