molcovert.bat %CLASSPATH% problem

User 9cf2153104

30-11-2011 13:23:39

Hi,


 


with version 5.7.0 of MarvinBeans molcovert.bat was changed in a way that breaks my scripts.


In 5.6.0.x the global %CLASSPATH% variable was used and "..\lib\MarvinBeans.jar" was appended (and later on removed again).


In version 5.7.0 the DOS variable %~d0 is used to determine the location of molconvert.bat what works fine when I start it from the command prompt. This method fails when I call it from an external script (in my case AutoIt 3), then %~d0 returns a string in which the location of the calling script and the location of molconvert.bat are concatenated, with the result that molconvert.bat exits with a "Main class not found" error.


I will try to figure out if this is an AutoIt or Windows bug, but for the moment it'd be great if the developers could take into account, that the method using the %~d0 variable is not safe under all circumstances.


Actually I'll patch molcovert.bat and use a fix path. If someone knows a better way to bypass this problem, please tell me.


 


Best regards

ChemAxon 7c2d26e5cf

06-12-2011 12:43:29

I have tested two cases:


#1. molconvert.bat is referred by full path from the caller script.


call C:\Program Files\ChemAxon\MarvinBeans\bin\molconvert.bat

#2. molconvert.bat is in the PATH and its short name is given in the caller script.


call molconvert.bat

Both cases works for me. Of course the caller batch file and molconvert.bat are located in different directories.

User 9cf2153104

07-12-2011 14:28:55










Tamas wrote:

I have tested two cases:


#1. molconvert.bat is referred by full path from the caller script.


call C:\Program Files\ChemAxon\MarvinBeans\bin\molconvert.bat

#2. molconvert.bat is in the PATH and its short name is given in the caller script.


call molconvert.bat

Both cases works for me. Of course the caller batch file and molconvert.bat are located in different directories.



This is certainly something only showing up when calling the batch file from a AutoIt script and when more complex paramaters are passed to the batch file (e.g. quoted filenames etc.). So the circumstances to trigger the error should be extremely rare.


Actually I have trouble to reproduce this issue with my original scripts. Maybe I've modified something that I don't remember when trying to get it running again.


But if you are interested I could send you a little example script to demonstrate the problem.

ChemAxon 7c2d26e5cf

09-12-2011 10:46:20

Passing parameter between batch file is not an easy question.


If you manage to isolate a test case, where quotation causes problem by molconvert calling, please share it with us.

User 9cf2153104

15-12-2011 09:09:59










Tamas wrote:

Passing parameter between batch file is not an easy question.


If you manage to isolate a test case, where quotation causes problem by molconvert calling, please share it with us.



Here we go. I've attached some files to demonstrate the issue. Save the .bat and .au3 file to the same directory and run the .au3 file using AutoIt3 (http://www.autoitscript.com/site/autoit/). The screenshot shows the result on my machine.


Again, this is not a molconvert issue, rather a bug in AutoIt, MS DOS or in the interaction of both. Maybe I did something wrong, but finally the batch file fails to determine its own path and that's the crucial point.

ChemAxon 7c2d26e5cf

22-12-2011 18:22:35

Yes, it is not a molconvert issue. It seems to be an AutoIt bug.


To avoid parent dir detection issue, I suggest hardcoding the absolute path of the batch script into your au3 file.


I have found a forum topic on Internet where there are a couple of alternatives to get the directory path of a batch file.


http://weblogs.asp.net/whaggard/archive/2005/01/28/get-directory-path-of-an-executing-batch-file.aspx


It seems %0 gives more or less correctly the absolute path of the running batch file. When I inserted the following line into your test.bat


echo %0

and run it via test.au3. I get this result:


""""C:\dev\svn\AutoIt \test.bat"""\.."

User 9cf2153104

04-01-2012 11:08:50










Tamas wrote:

Yes, it is not a molconvert issue. It seems to be an AutoIt bug.


To avoid parent dir detection issue, I suggest hardcoding the absolute path of the batch script into your au3 file.



Actually I modified molconvert.bat to use a hardcoded path for CLASSPATH.


It's just annoying if things break between two versions and a pain to track down such issues