Store stdout in environment variable

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
 
P

Phil Robyn

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?
 
P

Phil Robyn

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 - - - - - - - -
 
B

BDB

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.
 
P

Phil Robyn

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
 
F

foxidrive

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
 
P

Phil Robyn

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. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top