public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Simple .cmd file works under Cygwin but not Window's cmd interpreter.
@ 2016-03-05 16:33 Andy Hall
  2016-03-05 21:50 ` Andrey Repin
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Hall @ 2016-03-05 16:33 UTC (permalink / raw)
  To: cygwin

This is a puzzle that I have not been able to sort out despite trying all sorts of variations.  Basically,  I maintain a
bunch of Crystal Reports  based on Crystal reports XI R2.  Sorry,  I have no choice there.    I have this installed and
running on a Widows 10 machine.   How I did that is another story.   Recently I was asked what it would take to
internationalize these reports.  Fortunately, CR has a mechanism that allows you to define your own functions that can
be used in reports which  allow you to access properties files containing the localized entities just as you would for a
normal Java app.   All well and good. 

So I set about trying to get this to work.   The plugin to CR XI R2, is not well integrated with the base system and a
bit of not so nice manual configuration is necessary.  You have to follow this to the letter, but that is not
sufficient.   Out of the box I could not get it to work.    So to debug what was going on I wrote a simple bash script
to try to get it to work.   Lo and behold this simple script works:

#!/bin/bash

echo " "
echo "CLASSPATH = $CLASSPATH"
echo " "
#JAVA_HOME=C":\Program Files (x86)\Java\jdk1.6.0_45"
echo "JAVA_HOME = $JAVA_HOME"
echo " "
echo "PATH = $PATH"

cd "/cygdrive/c/Program Files (x86)/Business Objects/Crystal Reports 11.5"
java -version
crw32.exe

Notice that this seem to do nothing but display some key variables and the run CR in its installation  directory, just
as the normal shortcut does.  It launches CR which finds the plugin and loads it.

Now I have a need to do the same outside of the Cygwin environment, so I wrote a simple equivalent .cmd file:

@Echo off

:: Display CLASSPATH
set CLASSPATH

:: Set and display JAVA_HOME
::set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
set JAVA_HOME

:: Add 32-bit JDK to PATH and display
::set PATH=%JAVA_HOME%\bin;%PATH%
set PATH

pushd C:\Program Files (x86)\Business Objects\Crystal Reports 11.5
java.exe -version
crw32.exe
popd

If I run this from a bash command prompt it works as well.  It also works if I launch cmd from bash and then run the cmd
file.  That makes sense.

But here is the puzzle,   If I simply click on the runCR.cmd file, say from  the file explorer,  CR launches but does
not find the plugin.  The same happens if I launch a Windows cmd window and run the cmd file outside of Cygwin. 

So the question is: “What could possibly be the difference between the Cygwin environment and the Windows cmd
environment that makes this work in one and not the other?”   I have examined the PATH used in the Cygwin environment
and set the PATH in the Windows environment to be identical.  No change.   I thought it might have to do with whether or
not a 32-bit or 64-bit JVM is configured in the path, but that does not seem to make a difference.   It fails if the JVM
in the path is 32-bit or 64-bit probably because CR really gets its JVM from a registry setting.

I am at a loss,   Does anybody have an idea?   

BTW, I would have expected the reverse to be the case:  works in Windows but not Cygwin.  

Andy Hall



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Simple .cmd file works under Cygwin but not Window's cmd interpreter.
  2016-03-05 16:33 Simple .cmd file works under Cygwin but not Window's cmd interpreter Andy Hall
@ 2016-03-05 21:50 ` Andrey Repin
  2016-03-07 18:46   ` Andy Hall
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Repin @ 2016-03-05 21:50 UTC (permalink / raw)
  To: Andy Hall, cygwin

Greetings, Andy Hall!

> This is a puzzle that I have not been able to sort out despite trying all
> sorts of variations. Basically, I maintain a bunch of Crystal Reports based
> on Crystal reports XI R2. Sorry, I have no choice there.
> I have this installed and running on a Widows 10 machine. How I did that is
> another story.
> Recently I was asked what it would take to internationalize these reports. 
> Fortunately, CR has a mechanism that allows you to define your own functions
> that can be used in reports which  allow you to access properties files
> containing the localized entities just as you would for a
> normal Java app.   All well and good. 

> So I set about trying to get this to work. The plugin to CR XI R2, is not
> well integrated with the base system and a bit of not so nice manual
> configuration is necessary.
> You have to follow this to the letter, but that is not sufficient.
> Out of the box I could not get it to work. So to debug what was going on I
> wrote a simple bash script to try to get it to work.
> Lo and behold this simple script works:

> #!/bin/bash

> echo " "
> echo "CLASSPATH = $CLASSPATH"
> echo " "
> #JAVA_HOME=C":\Program Files (x86)\Java\jdk1.6.0_45"
> echo "JAVA_HOME = $JAVA_HOME"
> echo " "
> echo "PATH = $PATH"

> cd "/cygdrive/c/Program Files (x86)/Business Objects/Crystal Reports 11.5"
> java -version
> crw32.exe

> Notice that this seem to do nothing but display some key variables and the
> run CR in its installation directory, just as the normal shortcut does.
> It launches CR which finds the plugin and loads it.

> Now I have a need to do the same outside of the Cygwin environment, so I
> wrote a simple equivalent .cmd file:

> @Echo off

> :: Display CLASSPATH
> set CLASSPATH

echo %CLASSPATH%

> :: Set and display JAVA_HOME
> ::set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
> set JAVA_HOME

echo %JAVA_HOME%

> :: Add 32-bit JDK to PATH and display
> ::set PATH=%JAVA_HOME%\bin;%PATH%
> set PATH

Just start Java from %ProgramData%\Oracle\Java\javapath\java.exe
In truth, it IS ALREADY in your %PATH%, if you didn't removed it.

> pushd C:\Program Files (x86)\Business Objects\Crystal Reports 11.5

CD /D "C:\Program Files (x86)\Business Objects\Crystal Reports 11.5"

> java.exe -version
> crw32.exe
> popd

> If I run this from a bash command prompt it works as well.  It also works
> if I launch cmd from bash and then run the cmd
> file.  That makes sense.

> But here is the puzzle, If I simply click on the runCR.cmd file, say from
> the file explorer, CR launches but does not find the plugin. 
> The same happens if I launch a Windows cmd window and run the cmd file outside of Cygwin.

Then the environment is different.
"set > file" in both CMD prompts and diff the output.

> So the question is: “What could possibly be the difference between the
> Cygwin environment and the Windows cmd environment that makes this work in
> one and not the other?”
> I have examined the PATH used in the Cygwin environment and set the PATH in
> the Windows environment to be identical. No change.

It may be some other environment variable.

> I thought it might have to do with whether or not a 32-bit or 64-bit JVM is
> configured in the path, but that does not seem to make a difference.
> It fails if the JVM in the path is 32-bit or 64-bit probably because CR
> really gets its JVM from a registry setting.

> I am at a loss, Does anybody have an idea?  

> BTW, I would have expected the reverse to be the case:  works in Windows but not Cygwin. 

If I were you, I'd remove all Java versions and then install only one, and see
if it works or not.


-- 
With best regards,
Andrey Repin
Sunday, March 6, 2016 00:31:40

Sorry for my terrible english...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Simple .cmd file works under Cygwin but not Window's cmd interpreter.
  2016-03-05 21:50 ` Andrey Repin
@ 2016-03-07 18:46   ` Andy Hall
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Hall @ 2016-03-07 18:46 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 6502 bytes --]

Andrey -

Thank you for the response.   I had already tried most of your suggestions in one form or another.    So below is my
latest try (reduced to the essentials) to find what works and what doesn’t.  The essential idea was to take the PATH out
of consideration by reducing it to a minimum in both the CMD and Cygwin environments.   This did not change the result
at all.  This is expected, because Crystal Reports does not itself depend on anything in the PATH.  The user defined
functions are dynamically loaded and installed when run under Cygwin but not when run in a Windows command window.

There are differences in the environments (attached) but I don’t see anything Cygwin has added or changed that would
make a difference.  After all, Crystal Reports knows nothing about Cygwin specific environment variables so anything
added by Cygwin should not affect the behavior.   There are a few things that are different (oddly) , but manually
setting these in either environments is a bit tedious.

Now there are some details about the way user defined functions are installed that are peculiar.  First of all,  the
CLASSPATH settings are obviously read from the registry by Crystal Reports, not from the environment.   This is one of
the nasty manual configuration settings I mentioned below.    It also reads the path to a JVM .dll from a registry
setting and this also has to be set  to get user defined functions working.   When running  the script below in a
Windows CMD window,  Crystal reports loads and runs, but it fails to load the user defined functions.  That works from a
bash prompt.   From experimentation, I know setting this registry value is necessary as running in the Cygwin
environment fails if this is not set.  It is possible, that there is something strange about .dll loading which causes
it to work in Cygwin but not on a CMD Window, but that seems unlikely.

@Echo off

set CR_HOME_DIR=C:\Program Files (x86)\Business Objects\Crystal Reports 11.5

:: Display CLASSPATH
echo CLASSPATH
echo %CLASSPATH%
echo.

:: Set and display JAVA_HOME
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
echo JAVA_HOME
echo %JAVA_HOME%
echo.

::  Set minimal path and add 32-bit JDK to PATH and display
set PATH=.;%JAVA_HOME%\bin
echo PATH
echo %PATH%
echo.

:: Display environment.  
set
java.exe -version
"%CR_HOME_DIR%"\crw32.exe

I am still very puzzled,

Andy Hall


> Greetings, Andy Hall!
> 
> > This is a puzzle that I have not been able to sort out despite trying all
> > sorts of variations. Basically, I maintain a bunch of Crystal Reports based
> > on Crystal reports XI R2. Sorry, I have no choice there.
> > I have this installed and running on a Widows 10 machine. How I did that is
> > another story.
> > Recently I was asked what it would take to internationalize these reports.
> > Fortunately, CR has a mechanism that allows you to define your own functions
> > that can be used in reports which  allow you to access properties files
> > containing the localized entities just as you would for a
> > normal Java app.   All well and good.
> 
> > So I set about trying to get this to work. The plugin to CR XI R2, is not
> > well integrated with the base system and a bit of not so nice manual
> > configuration is necessary.
> > You have to follow this to the letter, but that is not sufficient.
> > Out of the box I could not get it to work. So to debug what was going on I
> > wrote a simple bash script to try to get it to work.
> > Lo and behold this simple script works:
> 
> > #!/bin/bash
> 
> > echo " "
> > echo "CLASSPATH = $CLASSPATH"
> > echo " "
> > #JAVA_HOME=C":\Program Files (x86)\Java\jdk1.6.0_45"
> > echo "JAVA_HOME = $JAVA_HOME"
> > echo " "
> > echo "PATH = $PATH"
> 
> > cd "/cygdrive/c/Program Files (x86)/Business Objects/Crystal Reports 11.5"
> > java -version
> > crw32.exe
> 
> > Notice that this seem to do nothing but display some key variables and the
> > run CR in its installation directory, just as the normal shortcut does.
> > It launches CR which finds the plugin and loads it.
> 
> > Now I have a need to do the same outside of the Cygwin environment, so I
> > wrote a simple equivalent .cmd file:
> 
> > @Echo off
> 
> > :: Display CLASSPATH
> > set CLASSPATH
> 
> echo %CLASSPATH%
> 
> > :: Set and display JAVA_HOME
> > ::set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
> > set JAVA_HOME
> 
> echo %JAVA_HOME%
> 
> > :: Add 32-bit JDK to PATH and display
> > ::set PATH=%JAVA_HOME%\bin;%PATH%
> > set PATH
> 
> Just start Java from %ProgramData%\Oracle\Java\javapath\java.exe
> In truth, it IS ALREADY in your %PATH%, if you didn't removed it.
> 
> > pushd C:\Program Files (x86)\Business Objects\Crystal Reports 11.5
> 
> CD /D "C:\Program Files (x86)\Business Objects\Crystal Reports 11.5"
> 
> > java.exe -version
> > crw32.exe
> > popd
> 
> > If I run this from a bash command prompt it works as well.  It also works
> > if I launch cmd from bash and then run the cmd
> > file.  That makes sense.
> 
> > But here is the puzzle, If I simply click on the runCR.cmd file, say from
> > the file explorer, CR launches but does not find the plugin.
> > The same happens if I launch a Windows cmd window and run the cmd file outside of Cygwin.
> 
> Then the environment is different.
> "set > file" in both CMD prompts and diff the output.
> 
> > So the question is: “What could possibly be the difference between the
> > Cygwin environment and the Windows cmd environment that makes this work in
> > one and not the other?”
> > I have examined the PATH used in the Cygwin environment and set the PATH in
> > the Windows environment to be identical. No change.
> 
> It may be some other environment variable.
> 
> > I thought it might have to do with whether or not a 32-bit or 64-bit JVM is
> > configured in the path, but that does not seem to make a difference.
> > It fails if the JVM in the path is 32-bit or 64-bit probably because CR
> > really gets its JVM from a registry setting.
> 
> > I am at a loss, Does anybody have an idea?
> 
> > BTW, I would have expected the reverse to be the case:  works in Windows but not Cygwin.
> 
> If I were you, I'd remove all Java versions and then install only one, and see
> if it works or not.
> 
> 
> --
> With best regards,
> Andrey Repin
> Sunday, March 6, 2016 00:31:40
> 
> Sorry for my terrible english...

[-- Attachment #2: envcmd.txt --]
[-- Type: text/plain, Size: 1978 bytes --]

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Andy\AppData\Roaming
BINDIR=C:\cygwin64\home\Andy\CRUFLS\
BINDRIVE=C:
BINPATH=\cygwin64\home\Andy\CRUFLS\
CLASSPATH=C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\CrystalFormulas.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\CrystalReportingCommon.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\u211java.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\external\icu4j.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\external\log4j.jar;C:\cygwin64\home\Andy\CRUFLS\lib\MyFunctions.jar
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=ANDY-WORK
ComSpec=C:\WINDOWS\system32\cmd.exe
CR_HOME_DIR=C:\Program Files (x86)\Business Objects\Crystal Reports 11.5
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Andy
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
LOCALAPPDATA=C:\Users\Andy\AppData\Local
LOGONSERVER=\\ANDY-WORK
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=.;C:\Program Files (x86)\Java\jdk1.6.0_45\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 15 Stepping 11, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f0b
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\Andy\AppData\Local\Temp
TMP=C:\Users\Andy\AppData\Local\Temp
USERDOMAIN=Andy-Work
USERDOMAIN_ROAMINGPROFILE=Andy-Work
USERNAME=Andy
USERPROFILE=C:\Users\Andy
windir=C:\WINDOWS
windows_tracing_flags=3
windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log

[-- Attachment #3: envcyg.txt --]
[-- Type: text/plain, Size: 2711 bytes --]

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Andy\AppData\Roaming
BINDIR=C:\cygwin64\home\Andy\CRUFLS\
BINDRIVE=C:
BINPATH=\cygwin64\home\Andy\CRUFLS\
CLASSPATH=C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\CrystalFormulas.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\CrystalReportingCommon.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\u211java.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\external\icu4j.jar;C:\Program Files (x86)\Business Objects\Common\3.5\java\lib\external\log4j.jar;C:\cygwin64\home\Andy\CRUFLS\lib\MyFunctions.jar
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMPUTERNAME=ANDY-WORK
COMSPEC=C:\WINDOWS\system32\cmd.exe
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
CR_HOME_DIR=C:\Program Files (x86)\Business Objects\Crystal Reports 11.5
EXECIGNORE=*.dll
FP_NO_HOST_CHECK=NO
HOME=C:\cygwin64\home\Andy
HOMEDRIVE=C:
HOMEPATH=\Users\Andy
HOSTNAME=Andy-Work
INFOPATH=/usr/local/info:/usr/share/info:/usr/info
INSTALL_DIR=/home/Andy
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
LANG=en_US.UTF-8
LOCALAPPDATA=C:\Users\Andy\AppData\Local
LOGONSERVER=\\ANDY-WORK
NUMBER_OF_PROCESSORS=2
OLDPWD=/home/Andy
ORIGINAL_PATH=/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Perforce:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/c/Program Files (x86)/SSH Communications Security/SSH Secure Shell
OS=Windows_NT
PATH=.;C:\Program Files (x86)\Java\jdk1.6.0_45\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PRINTER=HP LaserJet 400 M401 PCL 6
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 15 Stepping 11, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f0b
PROFILEREAD=true
PROGRAMFILES=C:\Program Files
PROMPT=$P$G
PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ 
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
PWD=/home/Andy/CRUFLS
ProgramData=C:\ProgramData
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
SESSIONNAME=Console
SHELL=/bin/bash
SHLVL=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINDOWS
TEMP=C:\cygwin64\tmp
TERM=xterm
TMP=C:\cygwin64\tmp
TZ=America/Los_Angeles
USER=Andy
USERDOMAIN=Andy-Work
USERDOMAIN_ROAMINGPROFILE=Andy-Work
USERNAME=Andy
USERPROFILE=C:\Users\Andy
WINDIR=C:\WINDOWS
_=./CRcyg.cmd
windows_tracing_flags=3
windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log


[-- Attachment #4: Type: text/plain, Size: 218 bytes --]

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-07 18:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-05 16:33 Simple .cmd file works under Cygwin but not Window's cmd interpreter Andy Hall
2016-03-05 21:50 ` Andrey Repin
2016-03-07 18:46   ` Andy Hall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).