|
|
|||||||
Hi, In a kix script, i launch a batch file with the SHELL command. For ex :SHELL "%COMSPEC% /C toto.bat" The batch file initializes some environment variables. Then i want to work with these variables in the rest of the kix script. What is the best way of doing to have what i look for ? ATM i can't get back the environnement variables... Thankx for any help Willou |
||||||||
|
|
|||||||
Well i forgot : script runs under WinNT/Win2K |
||||||||
|
|
|||||||
You might want to read the KiXtart Manual, commands EXPANDENVIRONMENTVARS, SET, SETL, SETM. Why not use KiXtart variables directly? [ 22. November 2002, 18:59: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
...RTFM... code:$Y = "And this is how you access environment variables: %USERNAME%..." |
||||||||
|
|
|||||||
waltz, that most likely is not the solution as sets done in child do not get into the script (RTFM) including the batch-file in your script would seem to be the best solution. |
||||||||
|
|
|||||||
yah, playing with envars is kinda like living on a dead-end one-way street... |
||||||||
|
|
|||||||
so... "You might want to read the KiXtart Manual, commands EXPANDENVIRONMENTVARS, SET, SETL, SETM." ->yeah i know them and they dont do anything for me in this case..Except perhaps ëxpandenvironmentvars as i havent got time to test it. "Why not use KiXtart variables directly?" -> because i want to get environment variable created BY the batch file... "$Y = "And this is how you access environment variables: %USERNAME%..." -> And this is how it doesnt works in this case... "waltz, that most likely is not the solution as sets done in child do not get into the script (RTFM) including the batch-file in your script would seem to be the best solution." -> Lonkero is the winner !! He understood my problem....Well i dont know how to do the same in kixstart as it is in the batch file :/ In fact, the bacth file get me the hour and minute of a machine on the network (net time command) After i do some calculation on the minute/hour in my kix script. So any solution to this ? Thgkx again for ur contribution |
||||||||
|
|
|||||||
Don't call the bat from KiX. Call it from logon.bat before you call KiX. |
||||||||
|
|
|||||||
See also, this: Topic: Setting Environment Variables with SET |
||||||||
|
|
|||||||
Willou, you can always post the batch and your kix script here asking for a translation to single KiX script ... I am quite sure the gang will take this as challenge Jochen |
||||||||
|
|
|||||||
So.... LLigetfa : it is not a logon script (i am examining ur link about environ variables). For "the gang", here is my challenge (nothing to win except my congratulations !) The kix script : #### $server = "x031768" SHELL "%COMSPEC% /C nettime.bat $server" ? "HOUR = %HH%" ? "Minutes = %MM%" #### The batch file (nettime.bat) : ### for /F "TOKENS=7,8 delims=: " %%a in ('net time \\%1') do ( set HH=%%a set MM=%%b ) ### |
||||||||
|
|
|||||||
so, isn't this same when you call the nettime.bat which does the calculation, where do you need time kixscript? |
||||||||
|
|
|||||||
Here u go : code:don't know if period is a proper name for PM / AM (we calculate here with 24 hrs )break on [ 25. November 2002, 13:40: Message edited by: jpols ] |
||||||||
|
|
|||||||
Willou, ammended above to return values rather than strings ! If you want to calculate with it later on this could be of interest for you : SerialTime() |
||||||||
|
|
|||||||
Thkx for ur contribution. jpol : i already think about using file but....i would prefer without In fact, i use the kixstart to : - read a server list - test access to the server - make access (with account) to the server - launch a batch to get time of the server (no equivalent command in kix) - calculate TIME + xx minutes more (in kix thats why i want) - schedule a job on server with TIME + XX minutes (via AT.exe (no equivalent command in kix so will be with a batch file too) - get @error to know if batch files goes well or not. If no solution for getting environment variables from the batch file, i will do all the rest of the kixstart script in a batch file (net time / calculation / schedule /etc.). Willou End |
||||||||
|
|
|||||||
Willou, there is no way (yet) to get back variables from shelled commands without tempfiles (Except you have WSH installed, then you can use WshPipe()) Think batch is a pain in the a** , I would rather pipe to files than use batch , but thats only my opinion By the way : be careful when adding x minutes to a given time (full hrs etc) Here is what I'v done in the latest SP distribution script using SerialTime() : code:translated: returns the hh:mm part of serialtime (remotes actual+10 mins)$time = left( SerialTime( ( SerialTime($rtime) + SerialTime("00:10:00") ) ) , 5) hth Jochen ps.: you can SHELL your at command with kix; it will set @error to 0 if successful ! pps: Caution - at works in 24 hr format so if time is PM you have to manipulate it once more [ 25. November 2002, 14:17: Message edited by: jpols ] |
||||||||
|
|
|||||||
Use the ScheduleTask() UDF to schedule tasks via the Task Scheduler on remote PCs. A lot of functionality is provided to KiXtart through UDFs if there is no native KiXtart function! You might also want to take a look at the KiXtart systems Manaement server threads. Everything you do can be done with pure KiXtart and the help of COM/ADSI. |
||||||||
|
|
|||||||
Hi jpols : dont care about calculation on time . the purpose of the script (atm) is to schedule a batch file between 5 and 30 mn more than remote time. So no need to calculate AM/PM (i only get back this statement to use it in the schedule process). sealeopard : Effectively, i began to look in the UDF library. There a re a lot of helpful function that looked for before. Thkx for ur help all Willou |