#33277 - 2002-11-22 06:46 PM
How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
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
|
Top
|
|
|
|
#33278 - 2002-11-22 06:48 PM
Re: How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
Well i forgot :
script runs under WinNT/Win2K
|
Top
|
|
|
|
#33283 - 2002-11-24 07:28 PM
Re: How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
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
|
Top
|
|
|
|
#33287 - 2002-11-26 12:10 AM
Re: How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
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 ) ###
|
Top
|
|
|
|
#33289 - 2002-11-26 12:27 AM
Re: How to get environ variables from a shell command ?
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Here u go :
code:
break on
$server = "x031768" $tmp = @scriptdir + "\" + @ticks + ".tmp"
shell '%ComSpec% /c net time \\' + $server + ' >' + $tmp
$ = open(1,$tmp) if not @error $time = readline(1) if instr($time, ':') $h = val(substr($time,instr($time,':')-2, 2)) $m = val(substr($time,instr($time,':')+1, 2)) $p = right($time, 2) "Hour = " + $h ? "Minutes = " + $m ? "period = " + $p else "Net time on " + $server + " failed ..." endif $ = close(1) del $tmp endif
get $
don't know if period is a proper name for PM / AM (we calculate here with 24 hrs ) [ 25. November 2002, 13:40: Message edited by: jpols ]
_________________________
|
Top
|
|
|
|
#33291 - 2002-11-25 01:50 PM
Re: How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
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
|
Top
|
|
|
|
#33292 - 2002-11-25 02:05 PM
Re: How to get environ variables from a shell command ?
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#33294 - 2002-11-26 02:18 PM
Re: How to get environ variables from a shell command ?
|
Willou
Fresh Scripter
Registered: 2002-11-22
Posts: 6
|
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
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|