Store stdout in environment variable

  • Thread starter Thread starter BDB
  • Start date Start date
B

BDB

I'm sure this is very basic. However, I couldn't find a FAQ topic for this
group.

I need to store the standard output of a program (w/arguments) into an
environment variable.

Could someone please post the correct syntax?

Thanks,
Bryan
 
BDB said:
I'm sure this is very basic. However, I couldn't find a FAQ topic for this
group.

I need to store the standard output of a program (w/arguments) into an
environment variable.

Could someone please post the correct syntax?

Thanks,
Bryan

How voluminous is the stdout of the program?
 
BDB said:
Fewer than 30 ASCII, printable (non-control) characters.

- - - - - - - - begin screen capture WinXP Pro SP2 - - - - - - - -
C:\cmd>inpath findstr.exe .
C:\WINDOWS\system32\findstr.exe

C:\cmd>for /f "tokens=*" %a in (
'findstr "13830" c:\cmd\data\FetchedBFPGL10jobs.sav'
) do set result=%a

C:\cmd>set result=BFPGL10D.JOB13830 20060207180045
- - - - - - - - end screen capture WinXP Pro SP2 - - - - - - - -
 
Phil Robyn said:
- - - - - - - - begin screen capture WinXP Pro SP2 - - - - - - - -
C:\cmd>inpath findstr.exe .
C:\WINDOWS\system32\findstr.exe

C:\cmd>for /f "tokens=*" %a in (
'findstr "13830" c:\cmd\data\FetchedBFPGL10jobs.sav'
) do set result=%a

C:\cmd>set result=BFPGL10D.JOB13830 20060207180045
- - - - - - - - end screen capture WinXP Pro SP2 - - - - - - - -

You're kidding, right? There must be a more straight forward way.
 
BDB said:
You're kidding, right? There must be a more straight forward way.

OK, how about

program arguments > programstdout.file
set /p result=<programstdout.file
 
OK, how about

program arguments > programstdout.file
set /p result=<programstdout.file

not to forget the trusted:

@echo off
for /f "delims=" %%a in ('program.exe /switches') do set var=%%a
 
foxidrive said:
not to forget the trusted:

@echo off
for /f "delims=" %%a in ('program.exe /switches') do set var=%%a

That was my original example in my first reply. :-)
 
Back
Top