Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

best way to *quickly* list environment variables, but not their values?

Jul
254
6
Right now i'm running set through sed, but it takes overhead and I'm trying to make some things go faster.

Is there an internal way to list all environment variable NAMES without listing their values?
 
The following requires the ffields command from the TextUtils Plugin;
Code:
set |! ffields /e /f:$0=20L

Adjust the 20L accordingly, depending on the length of your environment variable names.

Joe
 
Hmmm well, the site you linked to can't be reached (http://prospero.unm.edu/ is down completely), the plugin isn't listed on the official plugins page, and googling for it only seems to find android apps and a forum page here talking about it, so I don't seem to be able to have a way to install that plugin to even try your solution, sorry.
 
That is a @Charles Dye plugin, so hopefully he can fix the issue with the download.

Joe
 
I found a copy in my archives.

Please find attached version v0.82.2

Joe
 

Attachments

  • textutils.zip
    462.4 KB · Views: 80
Hmmm well, the site you linked to can't be reached (http://prospero.unm.edu/ is down completely), the plugin isn't listed on the official plugins page, and googling for it only seems to find android apps and a forum page here talking about it, so I don't seem to be able to have a way to install that plugin to even try your solution, sorry.

I'm aware of the issue. UNM IT has blackholed my little server, for reasons which I don't clearly understand. I hope to get the issue resolved sometime next week. If not, I guess I'll be looking for web space elsewhere. Preferably free. Anyone have any good suggestions?
 
Well, I've got a Github site,
and I am definitely not a professional programmer.

I was a professional programmer when I was much younger,
but that was long before Github,
when CompuServe was the big thing.

Joe
 
The 4UTILS plugin has _ENVVARS (and a ton of other stuff). copy ftp://vefatica.net/4plugins/x64/4utils64.zip

Code:
v:\> echo %_envvars
ALLUSERSPROFILE APPDATA CMDLINE CMDLINE2 CommonProgramFiles CommonProgramFiles(x86) CommonProgramW6432 COMPUTERNAME ComSpec DriverData historyexclude HOMEDRIVE HOMEPATH lastproject LOCALAPPDATA LOGONSERVER MSBuildSDKsPath NUMBER_OF_PROCESSORS OneDrive OS Path PATHEXT POWERSHELL_DISTRIBUTION_CHANNEL PROCESSOR_ARCHITECTURE PROCESSOR_IDENTIFIER PROCESSOR_LEVEL PROCESSOR_REVISION ProgramData ProgramFiles ProgramFiles(x86) ProgramW6432 prompt PSModulePath PUBLIC SERVICE_SUFFIX SESSIONNAME SHRALIAS_SAVE_PATH SystemDrive SystemRoot TEMP titleprompt TMP USERDOMAIN USERDOMAIN_ROAMINGPROFILE USERNAME USERPROFILE windir WSLENV WT_PROFILE_ID WT_SESSION ZES_ENABLE_SYSMAN __VIP
 
And (you have Cygwin, right?) this will give you a newline-separated list.

Code:
set | cut -d "=" -f1
 
I'm aware of the issue. UNM IT has blackholed my little server, for reasons which I don't clearly understand.
Was that without warning? I can't even PING prospero (not sure if that's a surprise). IT must have been in on it at some point because prospero.unm.edu has DNS lookup.

Heehee! I've been retired (and lucky.syr.edu non-existent) for 6+ years. And I still get

Code:
v:\> dig +short lucky.syr.edu
128.230.13.36
 
Was that without warning? I can't even PING prospero (not sure if that's a surprise). IT must have been in on it at some point because prospero.unm.edu has DNS lookup.

No warning. I don't think any human being was aware of it until I put in a service ticket. Just some overzealous router programming, I think.

It would be nice if someone there would tell me why it's being blocked. They don't like Linux? They don't like anonymous FTP? Just too many connections from all over the world? If I can get Prospero back online again, I'm thinking I will drop FTP support altogether, just have HTTP. Not many browsers support FTP anymore.
 
Is prospero your own machine, sitting on your desk and administered by you? If so I'm surprised it lasted this long. Here, they did away with that sort of thing years ago.

At SU, there's IT support and there are the network gods, quite separate entities. The former will be glad to help you set up Outlook. The latter (last I knew) are in a locked-down building all their own and do not interact with the hoi polloi. Good luck! Keep us informed.
 
And (you have Cygwin, right?) this will give you a newline-separated list.

Code:
set | cut -d "=" -f1
Oh that's what I'm currently doing, but I wanted to go faster. I have 2605 env vars so it takes awhile ... adding ones for emojis really increased that processing time up to about 2 seconds.
 
The 4UTILS plugin has _ENVVARS (and a ton of other stuff). copy ftp://vefatica.net/4plugins/x64/4utils64.zip

Code:
v:\> echo %_envvars
ALLUSERSPROFILE APPDATA CMDLINE CMDLINE2 CommonProgramFiles CommonProgramFiles(x86) CommonProgramW6432 COMPUTERNAME ComSpec DriverData historyexclude HOMEDRIVE HOMEPATH lastproject LOCALAPPDATA LOGONSERVER MSBuildSDKsPath NUMBER_OF_PROCESSORS OneDrive OS Path PATHEXT POWERSHELL_DISTRIBUTION_CHANNEL PROCESSOR_ARCHITECTURE PROCESSOR_IDENTIFIER PROCESSOR_LEVEL PROCESSOR_REVISION ProgramData ProgramFiles ProgramFiles(x86) ProgramW6432 prompt PSModulePath PUBLIC SERVICE_SUFFIX SESSIONNAME SHRALIAS_SAVE_PATH SystemDrive SystemRoot TEMP titleprompt TMP USERDOMAIN USERDOMAIN_ROAMINGPROFILE USERNAME USERPROFILE windir WSLENV WT_PROFILE_ID WT_SESSION ZES_ENABLE_SYSMAN __VIP

I've never tried a TCC plugin before (and indeed, googling instructions to find out how only yields pages that talk about plugins, never ones that talk about how to install them, to the point of giving up)

but I did the intuitive-to-me thing and copied the dll into my tcmd folder and restarted TCC

and it doesn't seem to have taken effect, this doesn't work for me.
 
Thanks. I've always associated GitHub with, like, professional programmers who know what they're doing. But maybe they'll give space to ammy toors as well.

Nah, GitHub is for anybody. You could even use it as a personal backup for your own BAT files to pull old revisions if you so desired.

Though if someone wants to just throw files up to share, without any accompanying pages, I'd say dropbox or Mega is easier.

But GitHub is pretty awesome, I've only gotten into it this year and it's amazing. A bit complicated at times, but ChatGPT helps with those issues.
 
I've never tried a TCC plugin before (and indeed, googling instructions to find out how only yields pages that talk about plugins, never ones that talk about how to install them, to the point of giving up)

but I did the intuitive-to-me thing and copied the dll into my tcmd folder and restarted TCC

and it doesn't seem to have taken effect, this doesn't work for me.

PLUGIN /L filename.dll

If you get an error to the effect that the file is not a valid Win32 application, you may be trying to load a 32-bit .DLL into a 64-bit version of TCC, or vice versa. Also, be aware that some of Vincent's plugins require an Oniguruma .DLL; I don't recall off the top of my head whether 4Utils is one of those that does.

If you want TCC to load a plugin automatically at startup, create a directory named PlugIns in the TCC program directory, and copy the .DLL files there.
 
Nah, GitHub is for anybody. You could even use it as a personal backup for your own BAT files to pull old revisions if you so desired.

Thank you. If I'm unable to get Prospero back online, I will look into GitHub as an alternative.
 
Oh that's what I'm currently doing, but I wanted to go faster. I have 2605 env vars so it takes awhile ... adding ones for emojis really increased that processing time up to about 2 seconds.
With 2605 environment variables, _ENVVARS is likely to crash TCC. The buffer where a plugin _VARIABLE writes its result can only hold 32K characters. And _ENVVARS doesn't check for overrunning that buffer. Even if a buffer overrun were detected, the results would be incomplete.

@ClioCJS, do you have a particularly slow computer? Even after, do i=1 to 10000 ( set variable_with_long_name%i=%i ), this set | cut -d "=" -f1 > nul takes less that 0.4 sec (at 3.5 GHz).

If your 2 seconds is for writing the variable names to the terminal, it's the writing to the terminal that's the slow part and not the processing of the data.
 
@ClioCJS, do you have a particularly slow computer?

Far from it

<pasted summary>

AMD Ryzen 9 5950X 16-core 3.4/4.9GHz CPU on a Gigabyte x570 Aorus Ultra 1.2 motherboard, with 32G DDR4/4400Hz G.Skill TridentZ RGB RAM, an RTX 3060 12G video card, a 1TB WD Black SN850 PCIe 4.0
NVMe M.2 SSD (and a WD Black 18TB HDD), with a liquid cooling system (including Floe Ring RGB cpu light), 6 RGB case fans, all in a black Phanteks Eclipse P600S Silent ATX Mid-Tower case with a 1200W Enermax modular power supply.

Also, they aren't going to the console when doing this. (or are they? i'm not producing any visible output, at least)

Tho to be specific, i'm doing this regex:

Code:
            set|sed "s/=.*$//ig" >"%TMPFILE%"
 
That should be faster than sending the output to the terminal. This is considerably better than 2 seconds. I think CUT will be faster that SED (but I didn't test it).

Code:
v:\> do i=1 to 5000 ( set variable_with_long_name%i=%i )

v:\> timer /q & (set | cut -d "=" -f1 > %temp\set.tmp) & timer
Timer 1 off: 18:13:39  Elapsed: 0:00:00.667

I'm working on a change to _ENVVARS so that, instead of crashing TCC when the list is too long, it will return as much as it can along with a "data incomplete" message (to stderr).
 
That should be faster than sending the output to the terminal. This is considerably better than 2 seconds. I think CUT will be faster that SED (but I didn't test it).

Code:
v:\> do i=1 to 5000 ( set variable_with_long_name%i=%i )

v:\> timer /q & (set | cut -d "=" -f1 > %temp\set.tmp) & timer
Timer 1 off: 18:13:39  Elapsed: 0:00:00.667

I'm working on a change to _ENVVARS so that, instead of crashing TCC when the list is too long, it will return as much as it can along with a "data incomplete" message (to stderr).

oooh, i hadn't thought of using cut before, genius.

Alas, still 2.2 seconds but i think maybe it's 5-10% faster?? :)

1689588085522.png


I might just declare that this is how long this takes with so many variables. Maybe there's no faster way.
 
oooh, i hadn't thought of using cut before, genius.

Alas, still 2.2 seconds but i think maybe it's 5-10% faster?? :)

View attachment 4110

I might just declare that this is how long this takes with so many variables. Maybe there's no faster way.

With your CPU and a solid state drive, that surprises me. How big is your environment (set | wc)? In my test, my environment had 5052 lines, 5104 words, and 170178 characters. And, today it's even faster!

Code:
v:\> timer /q & (set | cut -d "=" -f1 > %temp\set.tmp) & timer
Timer 1 off: 11:18:14  Elapsed: 0:00:00.174

v:\> set | wc
   5052    5104  170178

ECHOing _ENVVARS is much faster but it's only getting 32K of the environment.

Code:
v:\> timer & echo %_envvars > t:\envvars.txt & timer
Timer 1 on: 11:22:26
_ENVVARS (4UTILS): Environment too large; data incomplete
Timer 1 off: 11:22:26  Elapsed: 0:00:00.003

v:\> d t:\envvars.txt
2023-07-17  11:22          32,753  envvars.txt
 
Also, do you have a TCSTART.BTM? Does it to a lot? If it's what's slowing things down, this (at/near the beginning) might help.

Code:
IF "%_PIPE %_TRANSIENT" != "0 0" QUIT
 
I do something similar, except the first line in my TCSTART.BTM reads:

@if %_pipe != 0 .or. %_transient != 0 .or. %_ide != 0 quit
 
Also, do you have a TCSTART.BTM? Does it to a lot? If it's what's slowing things down, this (at/near the beginning) might help.

Code:
IF "%_PIPE %_TRANSIENT" != "0 0" QUIT

That! That made it a lot faster!

I fear that will break things that i pipe to though? I don't know much about this transient business but it sounds like maybe it's exactly what I needed! Thanks omg!!

That brought it from 2.25s to 0.25s!
 
With your CPU and a solid state drive, that surprises me. How big is your environment (set | wc)? In my test, my environment had 5052 lines, 5104 words, and 170178 characters. And, today it's even faster!

Code:
v:\> timer /q & (set | cut -d "=" -f1 > %temp\set.tmp) & timer
Timer 1 off: 11:18:14  Elapsed: 0:00:00.174

v:\> set | wc
   5052    5104  170178

Mine was:
2791 3725 109031

So wow, yours is even bigger than mine with all the emojis i generated? Dang!
 

Similar threads

Back
Top