Thread View: alt.msdos.programmer
6 messages
6 total messages
Started by Kevin MacDonald
Mon, 04 Jan 1993 16:00
Help Required with Dos variables
Author: Kevin MacDonald
Date: Mon, 04 Jan 1993 16:00
Date: Mon, 04 Jan 1993 16:00
11 lines
906 bytes
906 bytes
Is there any way to display the contents of a single DOS variable? I know you can display all current variables by typing SET, but there doesn't appear to be any way to display variables individually. I'm trying to setup a user log for our novell server and I thought since the users login time and username can be stored in dos variables, the simplest way to accomplish what I want to do would be to redirect the contents of these variables to a file... but alas DOS doesn't seem to want to cooperate... Rob
Re: Help Required with Dos variables
Author: Robert W. Babcock
Date: Mon, 04 Jan 1993 17:06
Date: Mon, 04 Jan 1993 17:06
9 lines
900 bytes
900 bytes
In article <1993Jan4.160029.26833@newton.ccs.tuns.ca> macdonak@newton.ccs.tuns.ca (Kevin MacDonald) writes: >Is there any way to display the contents of a single DOS variable? >I know you can display all current variables by typing SET, but there >doesn't appear to be any way to display variables individually. In a batch file you could do something like echo COMSPEC is %COMSPEC% This can be redirected.
Re: Help Required with Dos variables
Author: Jeremy Mathers
Date: Mon, 04 Jan 1993 19:18
Date: Mon, 04 Jan 1993 19:18
26 lines
1731 bytes
1731 bytes
In article <babcock.12.0@cfa.harvard.edu> babcock@cfa.harvard.edu (Robert W. Babcock) writes: >In article <1993Jan4.160029.26833@newton.ccs.tuns.ca> macdonak@newton.ccs.tuns.ca (Kevin MacDonald) writes: > >>Is there any way to display the contents of a single DOS variable? >>I know you can display all current variables by typing SET, but there >>doesn't appear to be any way to display variables individually. > >In a batch file you could do something like > echo COMSPEC is %COMSPEC% >This can be redirected. Well, no, in fact, it can't. Batch file redirection doesn't work. While conceding that the inability to reference env vars directly from the shell is a enormous omission on the part of the COMMAND.COM designers (& I can already hear the 4DOSers gathering up their voices), I have had good luck with: set | grep VARNAME ************************************************************************ If you didn't get caught, did you really do it? - pynq@quads.uchicago.edu, who is still costing the net hundreds, if not thousands, of dollars, every time he posts - ************************************************************************
Re: Help Required with Dos variables
Author: Robert W. Babcock
Date: Tue, 05 Jan 1993 00:22
Date: Tue, 05 Jan 1993 00:22
11 lines
965 bytes
965 bytes
In article <1993Jan4.191855.9869@midway.uchicago.edu> pynq@quads.uchicago.edu (Jeremy Mathers) writes: >>In a batch file you could do something like >> echo COMSPEC is %COMSPEC% >>This can be redirected. > >Well, no, in fact, it can't. Batch file redirection doesn't work. What I meant was that you can add indirection to the command inside the BAT file, i.e. echo COMSPEC is %COMSPEC% >>%1 with suitable tests to make sure %1 is defined.
Re: Help Required with Dos variables
Author: Jon Freivald
Date: Thu, 07 Jan 1993 00:56
Date: Thu, 07 Jan 1993 00:56
42 lines
1871 bytes
1871 bytes
macdonak@newton.ccs.tuns.ca (Kevin MacDonald) writes:
> Is there any way to display the contents of a single DOS variable?
> I know you can display all current variables by typing SET, but there
> doesn't appear to be any way to display variables individually.
>
> I'm trying to setup a user log for our novell server and I thought
> since the users login time and username can be stored in dos
> variables, the simplest way to accomplish what I want to do would be
> to redirect the contents of these variables to a file... but alas
> DOS doesn't seem to want to cooperate...
>
> Rob
You don't specify what exactly you want to do, but here's a couple
examples: (We'll assume you're after the contents of a variable named
"USER")
DOS batch file:
echo %%USER%% > logfile
-or-
echo %USER% > logfile
Using one or two '%' is DOS version and command interpreter dependent -
experiment -- mostly I use the single until I find a place it barfs,
then add the other...
C (Turbo to be specific - check your library reference)
char user_var[20]; /* whatever length...? */
user_var = getenv("USER");
Hope this helps...
Jon
=============================================================================
Jon Freivald ( jaf%jaflrn@uunet.UU.NET )
Nothing is impossible for the man who doesn't have to do it.
PGP V2 public key available on request
=============================================================================
Re: Help Required with Dos variables
Author: Rich Holland
Date: Thu, 07 Jan 1993 19:35
Date: Thu, 07 Jan 1993 19:35
25 lines
1309 bytes
1309 bytes
Jon Freivald <jaf@jaflrn.UUCP> writes:
>macdonak@newton.ccs.tuns.ca (Kevin MacDonald) writes:
>> Is there any way to display the contents of a single DOS variable?
>> I know you can display all current variables by typing SET, but there
>> doesn't appear to be any way to display variables individually.
Sure it does!
>DOS batch file:
> echo %USER% > logfile
Yeah, those work, but then you have 'logfile' to deal with. What's wrong
with this: 'SET | FIND USER'
He's not trying to copy USER to NEWUSER, or he could use:
SET NEWUSER=%USER%
--
Rich Holland | INTERNET: holland@matt.ksu.ksu.edu
100 Jardine Terr., Apt A7 | BITNET : holland@ksuvm
Manhattan, KS 66502-3357 | UUCP : ...!rutgers!matt.ksu.ksu.edu!holland
char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads