web stats
Environment variables different from terminal when calling getenv - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2019, 05:41 AM
mfortin mfortin is offline
What's HL7?
 
Join Date: May 2019
Posts: 2
mfortin is on a distinguished road
Default Environment variables different from terminal when calling getenv

Hello guys,

I am trying to set an environment variable to use in Mirth, but it does not show up when I call

var tempdir = java.lang.System.getenv("TMP"); // returns null
logger.debug(java.lang.System.getenv());

{PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, LANGUAGE=en_CA:en, INVOCATION_ID=bc84eb42ff8e4a7c8ba270c72234b2cc, JOURNAL_STREAM=8:13430, OLDPWD=/usr/lib/jvm/java-8-openjdk-amd64/jre, PWD=/opt/mirthconnect, LANG=en_CA.UTF-8}


There should be other variables here, such as USER and HOME, which also return null when I call getenv("USER").

This is on a fresh Debian 9.9 install in Virtualbox, I installed VB guest additions and Mirth 3.7.1 (sh version) only.

Thanks for your help!


Here is the error log:

[2019-05-24 09:31:36,148] ERROR (com.mirth.connect.server.controllers.DonkeyEngine Controller:1570): Error executing global deploy script.
com.mirth.connect.server.util.javascript.JavaScrip tExecutorException: com.mirth.connect.server.MirthJavascriptTransforme rException: SOURCE CODE:
98: function doScript() {99: var tempdir = java.lang.System.getenv("TMP");100: 101: logger.debug(java.lang.System.getenv());102: 103: globalMap.put("testDir", tempdir);104: 105: var testDir = new Packages.java.io.File(globalMap.get("testDir"));10 6: if (!testDir.exists()) try {107:
testDir.mkdir();LINE NUMBER:
103DETAILS:
Wrapped java.lang.NullPointerException
at Deploy:103 (doScript)
at Deploy:113
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.execute(JavaScriptUtil.java:75)
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeGlobalDeployScript(JavaScriptUtil.jav a:431)
[...]
Reply With Quote
  #2  
Old 05-27-2019, 11:00 AM
mfortin mfortin is offline
What's HL7?
 
Join Date: May 2019
Posts: 2
mfortin is on a distinguished road
Default

The solution is to add this line

export VAR="value"

in /etc/init.d/mcservice

I'm not sure if that's a nice way to do it though.
Reply With Quote
  #3  
Old 05-30-2019, 11:51 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 841
agermano is on a distinguished road
Default

See the following solution. It still requires modifying /etc/init.d/mcservice, but it's a little cleaner as it moves all of your variable declarations to a different file.

https://unix.stackexchange.com/quest...ment-variables
Reply With Quote
Reply

Tags
debian, error, getenv, javascript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:58 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation