Jump to content

RunWait(@Comspec and Run("app.exe" "P1 P2 P3")


Guest RocTx
 Share

Recommended Posts

Guest RocTx

Well, I've been busting my head trying to get the following code to work.

All of the code works fine (I've tested it by > to a .log file). But the second to the

last line (code) simply does not work and the error message flashes by so quickly

I can't capture it and it won't ( > ) output to a txt/log file to see what it's doing.

Anyone have any ideas? I've read through almost all the faqs and topics but have

not found anything similar to it. Any help would be appreciated.

Environment:

XP Pro (as server)

Dell 640

512M Ram

Java 1.4.2._04

Java Path: C:\Program Files\Java\j2re1.4.2_04\bin (it is in %PATH% also)

Program Path: C:\Program Files\Lucane\server

Program name: server.bat (trying to convert to app.exe)

The two (in bold) at the end of the code, :D RunWait(@Comspec I cannot get to run.

Is this maybe a problem with java?

How can I capture the erro output? When I try to capture it with ">" all I get is an

empty file.

.bat Code:

echo off

echo.set TMPCLASSPATH=%%1;%%TMPCLASSPATH%%>~tmp.bat

set TMPCLASSPATH=

for %%i in (lib\*.jar) do call ~tmp.bat "%CD%\%%i"

del /F ~tmp.bat

java -classpath %TMPCLASSPATH% org.lucane.server.Server

set TMPCLASSPATH=

app.exe Code:

; Script Function: Startup Lucane Server

; Create a temporary file called "~Tmp.txt"

; This file will contain all the files in

; the ./lib folder

RunWait(@comspec & " /c Dir .\lib > ~Tmp.txt")

$file = FileOpen("~Tmp.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

Dim $Nline = ""

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

if @error = -1 Then ExitLoop

If StringInStr($line, "jar") Then

$line=StringTrimLeft($line,39)

$Nline = $Nline & "C:\Program Files\Lucane\server\lib\" & $line & ";"

; MsgBox(4096, "Line read:", $Nline)

EndIf

Wend

FileClose($file)

; Done with the file. Delete it.

FileDelete("~Tmp.txt")

; Set TMPCLASSPATH environment variable

EnvSet("TMPCLASSPATH", $Nline)

$Env = EnvGet("TMPCLASSPATH")

; MsgBox(4096, "Environment Path:", $Env)

;Start the Server

RunWait(@Comspec & " /c echo %TMPCLASSPATH% > TMPCLASS.LOG", "",)

RunWait(@Comspec & " /c java -classpath %TMPCLASSPATH% org.lucane.server.Server", "", )

; Run("java", "-classpath %TMPCLASSPATH% org.lucane.server.Server")

I have the above line Run( commented out on purpose.

Link to comment
Share on other sites

Guest RocTx

I added that code:

$_error= @error ;backup

Msgbox(0, "Error output", $_error)

and the error is " 0 ".

Blank like when I send output to txt/log file.

I've looked closely at the " and , and ' and syntax.

Maybe I'm missing something? Been at it for 2 days and trying every which way

syntax wise but nothing. I get the feeling it's really something simple and I'm just

missing it.

Thank for the quick response and tip though. :D

Link to comment
Share on other sites

Guest RocTx

Yes.. when the server.bat is run..

java -classpath %TMPCLASSPATH% org.lucane.server.Server

it does output to the DOS window shell screen.

It lists the services that it starts and then sits there with "Server is Ready" and no

interaction is required and no input is necessary. To stop it you do a "Ctrl-C" and

"yes" to terminate the batch job. I am trying to convert this to .exe so that I can

try and see if I can use "SrvAny" to start is as a service at boot time. I will try

your suggestion when I get back in the office tomorrow morning.

Thanks again for the tip...

RocTx :D

Link to comment
Share on other sites

Valik, thanks.. the /k worked so I can see what the error message is. And it is:

Exception in thread "main" java.lang.NoClassDefFoundError: Files\Lucane\server\l

ib\activation-1/0/2/jar;C:\Program

josbe, I tried your code:

RunWait(@Comspec & ' /c java -classpath ' & EnvGet("TMPCLASSPATH") & ' org.lucane.server.Server', '', @SW_HIDE)

but still got the same error as above.

The working server.bat

Starts up like:

C:\Program Files\Lucane\server>echo off

Jun 9, 2004 9:03:22 AM org.lucane.server.store.Store <init>

INFO: Using database backend

writeScript

Jun 9, 2004 9:03:23 AM org.lucane.server.Server loadInternalServices

INFO: Service 'org.lucane.applications.administrator' loaded.

Loads other services...

Ends like:

Jun 9, 2004 9:03:23 AM org.lucane.server.Server generateKeys

INFO: Generating keypair

Jun 9, 2004 9:03:24 AM org.lucane.server.Server main

INFO: Server is ready.

Thanks for the tips... I appreciate your help.

The search continues...

RocTx :D

Link to comment
Share on other sites

Valik!!!

That did it!!

It works like a charm now.

Those single (') and double (") quotes. I need to understand them more and how

and when to use which. But that seems to have done the trick!

Thanks a bunch!! :D

RocTx

Link to comment
Share on other sites

Hey there josbe!!

I understand Faq #7. It's the examples in the help file that turned me all around

and confused me. In the examples in the help files it clearly shows double quotes.

It doesn't explain them. Looking at the codes on here I can see how they're

used and understand them. You guys have been a great help and I'm learning.

Thanks again for your time and patience and your experience.

RocTx

P.S.

I've only been using AutoIt3 for the first time on this project.. I'm new to it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...