Ho to use DS System variables
Created: 29 Jan 2012 | 5 comments
Hi,
I've seen this post (which tells how to send job notification email)
also I've seen this list of system variables, but i didnt understand where these variables are located ?
on deployed machine ? or on the server side ?
I've being trying to execute #c code which actually uses those variables, by the next way :
StreamWriter sw = new StreamWriter("log.txt");
sw.WriteLine(Environment.ExpandEnvironmentVariables(@"%JOBNAME%"));
sw.Close();
but the output i get is just a %JOBNAME%...
if i use with system environment variables (%appdata%) for examp, everything works ...
any idea ?
thanks
Discussion Filed Under:
Comments
On the right track...
Some variables are on the deployed machine and some will be ont he server itself. The one that you are looking at above should be on the server. In order to take advantage of that variable, the job will need to be run "Locally on the Deployment Server".
Brian Hawver
Systems Engineer
Yaskawa America, Inc.
Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads.
but.....
i managed to work with those variables on deployed machine
by using batch file i wrote the variable value to txt file...
so why i cant use them in .Net code ?
The way DS performs its
The way DS performs its replacement of these special variables like %JOBNAME% is to parse the scripts which are directly passed through the engine before executing.
Compiled code (like .NET) cannot have 'token replacement' function performed on it, as in order to do so the engine would have to decompile the code, replace the tokens and recompile before executing.
The way I get around this is to have my compiled code accept arguments, and have this executed by DS. For example,
Kind Regards,
Ian./
Ian Atkin, Senior Developer for the ICT Support Team, Oxford University, UK
Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads<
other sulotion
First, thanks for the reason explanation !
what i actually did is to wrote all relevant variables to text file (execution of batch file) and then i'm reading it from the compiled .Net, I have many of argument to pass :)
set your own environment variables.
Or set the variables as environment variables in your embedded script before calling your script or executable:
Note that these System tokens are always in uppercase.
These system tokens are replaced in the first script (in this case the embedded script) and are replaced not only with "Locally on the deployment server" but also on normal tasks.
Would you like to reply?
Login or Register to post your comment.