Page 1 of 1
Return Server name from within TI
Posted: Tue Jan 06, 2009 9:45 am
by garry cook
Having a blonde moment - anyone tell me how I can return the server name from within a TI? Want to use it for a filepath reference.
TIA
Re: Return Server name from within TI
Posted: Tue Jan 06, 2009 9:57 am
by John Hobson
Interesting question Garry.
I think you might have to declare it yourself like ServerName = 'Fred' before being able to use it.
Looking at functions like
ServerShutDown(SaveData); and
ViewExtractSkipCalcsSet ('Category Plan', '999 Seed Plan 1A', 0);
you can see that there seems to be an implicit assumption that the server is the server if you see what I mean so maybe the programmers saw no need for you to be able to retrieve the server name programmatically?
Re: Return Server name from within TI
Posted: Tue Jan 06, 2009 10:19 am
by Renaud MARTIAL
Hello,
For my application, I've resolved this with a Process using the tm1s.cfg file as Datasource.
The delimiter type is 'Delimited', with '=' as separator. Therefore, there are two columns defined: V1 and V2.
When in the Data tab the value of V1 is 'ServerName', I store the value of V2 into a varable 'sServerName',
which is then returned to the caller process using a global variable.
I guess that it should also work on windows hosts ...
Regards,
Renaud.
Re: Return Server name from within TI
Posted: Mon Jan 12, 2009 11:57 pm
by paulsimon
Garry
There are a couple of approaches.
You could just set up a Cube to hold the server name. I tend to do this for file import paths etc. That way it is easy to change it between Dev and Prod Servers.
Another approach is to use the TI Function
GetProcessErrorFileDirectory
Since the ProcessErrorFileDirectory will generally be the same as the Database Directory, or the Logging Directory if you use one. That will generally be similar to the path for the Server, assuming that you are really trying to get at that, rather than the Server Name.
I am not sure when that was introduced. It might only have been 9.1.
Regards
Paul Simon
Re: Return Server name from within TI
Posted: Tue Jan 13, 2009 12:08 am
by Alan Kirk
PaulSimon wrote:
Another approach is to use the TI Function
GetProcessErrorFileDirectory
Since the ProcessErrorFileDirectory will generally be the same as the Database Directory, or the Logging Directory if you use one. That will generally be similar to the path for the Server, assuming that you are really trying to get at that, rather than the Server Name.
I am not sure when that was introduced. It might only have been 9.1.
It's been around since at least 8.4.4, but was causing intermittent crashes until it was fixed in 9.0 SP2.
Re: Return Server name from within TI
Posted: Tue Jan 13, 2009 12:37 am
by ScottW
GetProcessErrorFileDirectory will return the path on the server with trailing slash of the LoggingDirectory config parameter setting. If this setting is not used then by default it will return the path of the database directory.
Of course it's best practice that the logging directory is NOT the same as the database directory as
1/ this could result in a lot of log files being backed up unecessarily
2/ this would tend to indicate that the database directory is shared in order for users to read the log files, which is definitely not good practice.
To follow on from Renaud's tip I generally store server name, database dir and logging dir in a control cube and read the values into the cube via a TI that has tm1s.cfg as the source and "=" as the delimiter. (Note no need for full path for DatabaseNameForServer, just tm1s.cfg as if there is no path specified TI assumes the database directory.)
GetProcessErrorFileDirectory is pretty handy as it shortcuts having to specify a path for ASCIIOutput, you can just write to the logging directory. E.g.
Code: Select all
vFileNm = 'myErrFile.txt';
vFile = GetProcessErrorFileDirectory | vFileNm;
ASCIIOutput( vFile, 'whatever you want to write' );