baaneur
24th October 2002, 12:05
Hi,

How can I access client environment variables from the BaaN server ?
I want to transfer information from windows program to a BaaN session using temporary files.
So my BaaN session creates a temporary on the server using creat.tmp.file ( bse.tmp.dir$() ) and calls the windows program with app.start.
The windows program generate a tmp file in the BSE_TMP directory of the client.
Finally I want to transfer the client temporary file into my server temporary file but I can't because I don't know what BSE_TMP is.
Can anyone help me ?

Thanks

mark_h
24th October 2002, 16:01
I have never tried this but I wonder if %BSE_TMP% in the filename of the client2server command would work.

Mark

nick_rogers
24th October 2002, 17:05
Maybe I do not fully understand youre request, but the get.env$() function can retieve an env var:

getenv$
NAME getenv$ - function for retrieving environment variables
SYNOPSIS string GETENV$( string env_var(256) )
DESCRIPTION The function GETENV$ returns the value of the specified environment variable of the operating system. If the specified variable is not available an empty string ("") is returned.
Example:
string name(15)
name = getenv$("LOGNAME")

mark_h
24th October 2002, 17:13
Hi Nick!

getenv$ gets the server side enivironment variable and baaneur is looking for something to get environment variables from the windows client side. I am not sure if there is a baan function for this.

Mark

baaneur
24th October 2002, 17:18
Thank you for your replies but it doesn't solve my problem.
I tried using %BSE_TMP% and %%BSE_TMP%% too but it didn't work.
getenv$() is used only for the server's environment variables. You can't select client's ones.
I tried to use create.local.temp.file from ttdllfilehand DLL but I don't understand how this function works and what it must do.

isimeon
24th October 2002, 19:49
You can run set command on local machine:

app.start("set BSE_TMP >tmp.txt","c:\","","","")

and next read the file tmp.txt on local computer with seq.open.local(...), seq.read.local(...) and seq.close.local(...).

Depending on operating system on the client computer you can use

cmd /C set BSE_TMP >tmp.txt

or

start set BSE_TMP >tmp.txt

and using different switches.

Regards

baaneur
25th November 2002, 15:11
Thanks for your help but I've found the answer !!

It is very simple :
In all the functions used for local file handling (client2server, remove.local.file, ... see ottdllbw), you can use the baan syntax ${...} in strings to specify env. variables; i.e : if you want to remove the file TOTO in the BSE_TMP local directory, you use the command:
remove.local.file("${BSE_TMP}\TOTO")
and it's done !!!
So ${...} works for server and local files handling functions.

mark_h
25th November 2002, 15:19
Thanks for the update Baaneur. I am sure this prove useful to others in the future - myself included.

Mark

günther
15th February 2008, 16:03
Although this is a quite old thread, the main idea is still actual.

Most of the server2client() examples simply use "C:\temp" and all that stuff and so they will run into problems eg. on citrix clients when their admin does not allow to write to C:\.

So I tried the following (my baan is on unix):
1. rc = server2client(".profile", "C:\temp\test.txt", true) -- rc=0, works fine.
2. rc = server2client(".profile", "${TEMP}\test.txt", true) -- rc=0, no file in %TEMP% created.
3. rc = server2client(".profile", "$TEMP\test.txt", true) -- rc=-1, no file in %TEMP% created.
4. rc = server2client(".profile", "${%TEMP%}\test2.txt", true) -- dto.

Some other tests:
5. rc = server2client(".profile", "C:\temp\${TERM}.txt", true) -- rc=0, created a file C:\temp\${TERM}.txt, on unix side TERM is set to vt220, on windows side TERM is not set.
6. rc = server2client(".profile", "${HOMEDRIVE}\test.txt", true) -- rc=0, created a file X:\test.txt which is okay. HOMEDRIVE is only set on windows side.

@baaneur: Is your baan server on unix or on windows?

@all: Does one of my variants work on your system (unix + baan ivc4)?

günther
15th February 2008, 17:40
Meanwhile, I played with some other WINDOWS env vars.

${HOMEDRIVE} -- okay; X:
${HOMEDRIVE}\${HOMEPATH} -- okay; X:\
${HOMESHARE} -- okay; \\<machine>\...

${USERPROFILE} -- No! "C:\Dokumente und Einstellungen\..."; I guess the blanks are the problem (in germany).

${TMP} -- No! "C:\DOKUME~1\..."; I gues the tilde make the problem.
${TEMP} -- No! identical to ${TMP}

Hints on other countries / language settings appreciated.
Hints on standard WINDOWS env vars too.

günther

george7a
16th February 2008, 22:56
Hi,

I have also been in this question and found out that if you do not set the full path of the second argument in server2client function, BW will automatically copy the file to its default directory. Example:

rc = server2client(".profile", "test.txt", true)
This code might copy the file to %TEMP% or to the desktop or...
So I used this method to copy & activate a VB script that will return the %TEMP% in a text file. After that the Baan script will delete the temp files.

I can share the VB script when I am back in the office on Monday.

- George

baaneur
18th February 2008, 10:24
@gunther :
I'm surprised to see that this thread is not dead. Unfortunately, I don't work on baan anymore. Just to reply to your question, our baan server is on Unix.
Regards,

Baaneur

günther
18th February 2008, 11:21
rc = server2client(".profile", "test.txt", true) [/code]
This code might copy the file to %TEMP% or to the desktop or...

Okay, that works (rc=0). But if I try to find that file on the windows side, I don't see. I've tested some directories manually from the explorer.

Some programmed tests:
1. When I use rc = seq.fstat.local("test.txt", size), I get rc=0 (okay) and a size > 0, so the file *must* be on the windows side.

2. When I use a_string = get.local.filename() after the server2client call, a_string is empty atlhough it should contain the last filename. Did you manage to use that function?

Günther

george7a
18th February 2008, 11:26
I did not use get.local.filename before. What I did is that I wrote a VB script that gets %TEMP% and wrote it in a file and then the Baan Tools script read it. Thats how I knew where the "Default Temp" is.

NPRao
18th February 2008, 21:11
Refer to the link - Accessing Environment Variables (http://www.freeweb.hu/wsh2/ch07c.html)

Alternatively, you can use the Set command
C:\>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\prashanth\Application Data
BAANHOME=C:\Program Files\Baan\shared
CLASSPATH=C:\Program Files\Baan\shared\java\com_baan_bclm.jar;C:\Program Files\SSA-TA\Studio 2.6\java\b3devms.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\QTJava.zip;C:\Program Files\Infor\Infor Integration\java\ow.jar;C:\Documents and Settings\All Users\Application Data\Infor\Infor Integration\java;C:\Program Files\
Infor\Infor Integration\java\ow3p.jar;C:\Program Files\Baan\shared\bin;C:\Program Files\Baan\shared\shlib;C:\Program Files\Baan\shared\java\com_baan_bclm.jar;C:\Program Files\SSA-TA\Studio 2.6\java\b3devms.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\QTJava.zip;C:\Program Files\Infor\Infor Integration\java\ow.jar;C:\
Documents and Settings\All Users\Application Data\Infor\Infor Integration\java;C:\Program Files\Infor\Infor Integration\java\ow3p.jar;C:\Program Files\Baan\shared\bin;C:\Program Files\Baan\shared\shlib
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=PFC303502
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\prashanth
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_12
LOGONSERVER=\\CNFQC045
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\Program Files\BMC Software\CONTROL-M EM 6.3.01\Default\SybClient\OCS-12_5\bin;C:\Program Files\Java\jdk1.5.0_12\bin;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\E!TCP;C:\Program Files\UltraEdit;C:\Program Files\Baan\shared\bin;C:\Program Files\Baan\shared\shlib;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\ATI Technologies\ATI Control Panel;C:\PROGRA~1\ATT\Graphviz\bin;C:\Program Files\Infor\Infor Integration\bin;C:\Program Files\Java\jre1.6.0_02\bin\client;C:\Program Files\SLM\bin;C:\Program Files\SLM\shlib
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 6, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0d06
ProgramFiles=C:\Program Files
PROMPT=$P$G
QTJAVA=C:\Program Files\Java\j2re1.4.2_07\lib\ext\QTJava.zip
SESSIONNAME=Console
SLMHOME=C:\Program Files\Baan\shared
SLM_API_SL=SlmClient
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\prashanth\LOCALS~1\Temp
TMP=C:\DOCUME~1\prashanth\LOCALS~1\Temp
USERDNSDOMAIN=CNF.PROD.CNF.COM
USERDOMAIN=CFI
USERNAME=prashanth
USERPROFILE=C:\Documents and Settings\prashanth
WF_RESOURCES=C:\oracle\ora92\WF\RES\WFus.RES
windir=C:\WINDOWS

C:\> set /?
Displays, sets, or removes cmd.exe environment variables.

SET [variable=[string]]

variable Specifies the environment-variable name.
string Specifies a series of characters to assign to the variable.

Type SET without parameters to display the current environment variables.

If Command Extensions are enabled SET changes as follows:

SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command. For example:

SET P

would display all variables that begin with the letter 'P'

SET command will set the ERRORLEVEL to 1 if the variable name is not
found in the current environment.

SET command will not allow an equal sign to be part of the name of
a variable.

Two new switches have been added to the SET command:

SET /A expression
SET /P variable=[promptString]


C:\>set t
TEMP=C:\DOCUME~1\prashanth\LOCALS~1\Temp
TMP=C:\DOCUME~1\prashanth\LOCALS~1\Temp

C:\>set temp
TEMP=C:\DOCUME~1\prashanth\LOCALS~1\Temp