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

Windows bat files

2 replies
kolotyluk
Joined: 2010-06-04,
User offline. Last seen 5 weeks 16 hours ago.

I have a hello.bat file with the following contents

@scala -cp classes Hello
@echo one
@echo two
@scala -cp classes Hello

The first Hello program runs, but the bat file execution stops right
after that, so none of the rest of the command lines get executed.

What's up with that? Why does the bat file terminate after running the
Scala program?

On the other hand the following bat file runs properly as expected

@java -cp classes Hello
@echo one
@echo two
@java -cp classes Hello

Cheers, Eric

DaveScala
Joined: 2011-03-18,
User offline. Last seen 1 year 21 weeks ago.
Re: Windows bat files

scala is a batch file: scala.bat
If you want to call a batch file from a batch file and return control
to the main batch file you use call
like so

@call scala -cp classes Hello
@echo one
@echo two
@call scala -cp classes Hello

On 11 sep, 22:55, Eric Kolotyluk wrote:
> I have a hello.bat file with the following contents
>
> @scala -cp classes Hello
> @echo one
> @echo two
> @scala -cp classes Hello
>
> The first Hello program runs, but the bat file execution stops right
> after that, so none of the rest of the command lines get executed.
>
> What's up with that? Why does the bat file terminate after running the
> Scala program?
>
> On the other hand the following bat file runs properly as expected
>
> @java -cp classes Hello
> @echo one
> @echo two
> @java -cp classes Hello
>
> Cheers, Eric

kolotyluk
Joined: 2010-06-04,
User offline. Last seen 5 weeks 16 hours ago.
Re: Re: Windows bat files

Thanks - that does the trick. Now I feel so dumb.

I wasn't paying attention to what is in %SCALA_HOME%\bin - it's all
script files.

Cheers, Eric

On 2011-09-11 2:38 PM, Dave wrote:
> scala is a batch file: scala.bat
> If you want to call a batch file from a batch file and return control
> to the main batch file you use call
> like so
>
> @call scala -cp classes Hello
> @echo one
> @echo two
> @call scala -cp classes Hello
>
> On 11 sep, 22:55, Eric Kolotyluk wrote:
>> I have a hello.bat file with the following contents
>>
>> @scala -cp classes Hello
>> @echo one
>> @echo two
>> @scala -cp classes Hello
>>
>> The first Hello program runs, but the bat file execution stops right
>> after that, so none of the rest of the command lines get executed.
>>
>> What's up with that? Why does the bat file terminate after running the
>> Scala program?
>>
>> On the other hand the following bat file runs properly as expected
>>
>> @java -cp classes Hello
>> @echo one
>> @echo two
>> @java -cp classes Hello
>>
>> Cheers, Eric

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