Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run a bat in a new dos window

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can write an ant task that runs a certain bat file; what i want is a way to have it running in a new (dos) window

how can i do it?

TiA
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you want to accomplish?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my bat launches an hsqldb server instance; what i want is the ability to manually close the server if i wish so (by closing the dos window); as i have it now, even after closing the dos window server keeps alive
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me try to put it in another way:
when i run junit4 task (which depends on run bat file), it runs a bat file; since this results in getting a db server running, it stands alive, so the junit task itself never gets an oportunity to execute.
so, i'd like my task to launch the bat file in another dos window, so that my tests could get a chance to run
here's how it looks like:
C:\javaGranel\tag>ant junit4
Buildfile: build.xml

compilaRapido:

bat:

[exec] C:\javaGranel\tag>cd C:\javagranel\tag\data

[exec] C:\javaGranel\tag\data>java -classpath ../lib/hsqldb.jar org.hsqldb.Server
[exec] [Server@1a758cb]: [Thread[main,5,main]]: checkRunning(false) entered
[exec] [Server@1a758cb]: [Thread[main,5,main]]: checkRunning(false) exited
[exec] [Server@1a758cb]: Startup sequence initiated from main() method
[exec] [Server@1a758cb]: Loaded properties from [C:\javaGranel\tag\data\server.properties]
[exec] [Server@1a758cb]: Initiating startup sequence...
[exec] [Server@1a758cb]: Server socket opened successfully in 109 ms.
[exec] [Server@1a758cb]: Database [index=0, id=0, db=file:test, alias=] opened sucessfully
in 1141 ms.
[exec] [Server@1a758cb]: Startup sequence completed in 1250 ms.
[exec] [Server@1a758cb]: 2006-09-08 14:30:11.750 HSQLDB server 1.8.0 is online
[exec] [Server@1a758cb]: To close normally, connect and execute SHUTDOWN SQL
[exec] [Server@1a758cb]: From command line, use [Ctrl]+[C] to abort abruptly

and it stays there forever, so i've to manually keystroke control+C and finally answer y to y/n question, but, when i do it, the batch ends, and tests never run - and more - server isnt shut down

if i procceed, i get this time:
Pretende terminar a tarefa batch (S/N)? s

C:\javaGranel\tag>ant junit4
Buildfile: build.xml

compilaRapido:

bat:

[exec] C:\javaGranel\tag>cd C:\javagranel\tag\data

[exec] C:\javaGranel\tag\data>java -classpath ../lib/hsqldb.jar org.hsqldb.Server
[exec] [Server@1a758cb]: [Thread[main,5,main]]: checkRunning(false) entered
[exec] [Server@1a758cb]: [Thread[main,5,main]]: checkRunning(false) exited
[exec] [Server@1a758cb]: Startup sequence initiated from main() method
[exec] [Server@1a758cb]: Loaded properties from [C:\javaGranel\tag\data\server.properties]
[exec] [Server@1a758cb]: Initiating startup sequence...
[exec] [Server@1a758cb]: [Thread[HSQLDB Server @1a758cb,5,main]]: run()/openServerSocket():

[exec] java.net.BindException: Address already in use: JVM_Bind
[exec] [Server@1a758cb]: Initiating shutdown sequence...
[exec] at java.net.PlainSocketImpl.socketBind(Native Method)
[exec] [Server@1a758cb]: Shutdown sequence completed in 16 ms.
[exec] at java.net.PlainSocketImpl.bind(Unknown Source)
[exec] [Server@1a758cb]: 2006-09-08 14:32:30.328 SHUTDOWN : System.exit() is called next
[exec] at java.net.ServerSocket.bind(Unknown Source)
[exec] at java.net.ServerSocket.<init>(Unknown Source)
[exec] at java.net.ServerSocket.<init>(Unknown Source)
[exec] at org.hsqldb.HsqlSocketFactory.createServerSocket(Unknown Source)
[exec] at org.hsqldb.Server.openServerSocket(Unknown Source)
[exec] at org.hsqldb.Server.run(Unknown Source)
[exec] at org.hsqldb.Server.access$000(Unknown Source)
[exec] at org.hsqldb.Server$ServerThread.run(Unknown Source)

junit4:
[java] JUnit version 4.1
[java] .............................
[java] Time: 4,359

[java] OK (29 tests)


BUILD SUCCESSFUL
Total time: 8 seconds
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miguel,
Take a look at the spawn attribute of the exec task. Note that you will probably also want to use the waitFor task to allow the server to start up before running your integrationt tests.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Miguel,
Take a look at the spawn attribute of the exec task. Note that you will probably also want to use the waitFor task to allow the server to start up before running your integrationt tests.

Bingo!
i didnt feel the need of waitFor because first thing to happen in my task is precisely the server setup
thanks a lot, Jeanne!

PS please help me because when i try to post my build's relevant part i get a persistent error message stating i've to change '<' with &l t;, but even doing it i cant post

[ September 09, 2006: Message edited by: miguel lisboa ]
[ September 09, 2006: Message edited by: miguel lisboa ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by miguel lisboa:
PS please help me because when i try to post my build's relevant part i get a persistent error message stating i've to change '<' with &l t;, but even doing it i cant post

<target name="testingEscapeCharacters>

[edited to try alternatives for escape characters]
[ September 09, 2006: Message edited by: Jeanne Boyarsky ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
??? &lt; works for me.

You can try running your code through Eric's tool. Maybe you missed one <?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks again, Jeanne, but i've bad news: i hurried myself, so it doesnt perform like i intended to... i mean, server keeps running
i noticed ant has WLSTOP that stops a weblogic server, but that's all, i guess
now let me try your sugestion:
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i came to an workable solution, though not quite elegant:
<target name = "junit4Incompleto" depends = "compilaRapido, bat">

<condition property = "SuiteClass" value = "${SuiteClass}">

<isset property = "SuiteClass" />

</condition>

<property name = "SuiteClass" value = "testes.TodosOsTestes" />

<java classname = "org.junit.runner.JUnitCore" fork = "yes" classpathref = "libraries">

<arg value = "${SuiteClass}" />

<classpath refid = "classpath" />

</java>

</target>



<target name = "junit4" depends = "junit4Incompleto">

<java classname = "persistencia.Hsql" fork = "yes" classpathref = "libraries">

<classpath refid = "classpath" />

</java>

</target>
and Hsql.java:
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you'r welcome!
its a poor solution since whole proccess takes 8 seconds, while running tests takes only aprox. 3
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic