Sholom there!
Trying to write 2nd's cmd window's stdout that starts from 1st cmd to a variable but haven't succeed yet... Seems to me that some redirection with "1", "2", "&" must take place, but don't know how to do it... Here's my trying:
for /f "usebackq tokens=2 delims=: " %i in (`start /i pmon.exe ^|findstr /i "memory"`) do echo %i
Here the 2nd processing cmd line of the pmon.exe proccess:
Memory: 2000000K Avail: 500000K PageFlts: 15000 InRam Kernel:10000K P:200000K
The result must be "2000000K" in 1st window, 2nd window must be closed. Thanks .
Read window line from parent cmd without writing to file
Moderator: DosItHelp
-
- Posts: 16
- Joined: 15 Jul 2019 15:14
Read window line from parent cmd without writing to file
Last edited by Izya Kurvitch on 24 Mar 2023 06:00, edited 1 time in total.
Re: Read window line from parent cmd
What happens if you remove the 'start' command?
Saso
Code: Select all
for /f "usebackq tokens=2 delims=: " %i in (`pmon.exe ^|findstr /i "memory"`) do echo %i
-
- Posts: 16
- Joined: 15 Jul 2019 15:14
Re: Read window line from parent cmd
miskox wrote: ↑23 Mar 2023 06:24What happens if you remove the 'start' command?
SasoCode: Select all
for /f "usebackq tokens=2 delims=: " %i in (`pmon.exe ^|findstr /i "memory"`) do echo %i
Nothing. The cursor hangs in the parental window, and the pmon.exe window does not start ... It could be another cmd utility, not necessary pmon.exe. The idea is to read line in secondary window and output it to parental one.
Re: Read window line from parent cmd
Run pmon.exe only and post the results (between code tags, please).
Saso
Saso
-
- Posts: 16
- Joined: 15 Jul 2019 15:14
Re: Read window line from parent cmd
Here the first line of the pstat.exe window... others are similar:
Code: Select all
Pstat version 0.2: memory: 2000000 kb uptime: 1 5:49:06.598
Code: Select all
@echo off
pstat.exe>c:\1.txt
for /f "usebackq tokens=5 delims=: " %%i in ('findstr "memory" "c:\1.txt"') do @echo %%i
2000000
I trust him, as he's an expert, but still seeking a way to do it without writing to file using operative memory only...It sounds like you are trying to communicate between different processes, which would require communication via files. I use that technique in my SNAKE.BAT batch game. Buried in that thread is a description of how the inter-process communication works.
Last edited by Izya Kurvitch on 24 Mar 2023 06:03, edited 1 time in total.
Re: Read window line from parent cmd
Accordingly to your last test, this should work:
Note that you changed the "backtit" ("`" character) by apostrophe...
If this not works, remove the usebackq option from FOR /F switch.
Antonio
Code: Select all
for /f "usebackq tokens=5 delims=: " %%i in ('pstat.exe ^| findstr /i "memory"') do echo %%i
If this not works, remove the usebackq option from FOR /F switch.
Antonio
-
- Posts: 16
- Joined: 15 Jul 2019 15:14
Re: Read window line from parent cmd
Of course, it's my inattention... Tnaks for your notice.Aacini wrote: ↑23 Mar 2023 19:51Accordingly to your last test, this should work:
Note that you changed the "backtit" ("`" character) by apostrophe...Code: Select all
for /f "usebackq tokens=5 delims=: " %%i in ('pstat.exe ^| findstr /i "memory"') do echo %%i
If this not works, remove the usebackq option from FOR /F switch.
Antonio
Code: Select all
@echo off
pstat.exe>c:\1.txt
for /f "tokens=5 delims=: " %%i in ('findstr "memory" "c:\1.txt"') do @echo %%i
2000000