Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Collecting stdout into DOS variable

Posted on 2006-07-01
4
1,420 Views
Last Modified: 2012-08-13
I am new to DOS programming - I have written a batch script to execute a program and write stdout to a file.
I am not gettign the syntax to collect it into a variable instead of a file.Is there a way?
pardon my ignorance.
I am using the following syntax now:
set STDERR=stderr.txt
REM time the job by writing timestamps to a file
echo Begin at: 1>%STDOUT% 2>%STDERR%
time /T 1>>%STDOUT% 2>>%STDERR%
date /T 1>>%STDOUT% 2>>%STDERR%

REM run the j
IEClient.exe %* 1>>%STDOUT% 2>>%STDERR%

Can stdout be collected into a variable directly.
or do i have to repoen the output file into a variable?
0
Comment
Question by:ranadhir
4 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 50 total points
ID: 17037059
Short answer anyway is no.  You are redirecting to the contents of the variable, i.e. a file called blank.  You can redirect to a file then use a for command to read the first or a specific line of the file into a variable.  Ask if that is what you want (here or in MS-DOS)... more points might help too.

BTW From W2K up you can use

set stdout=stdout.txt
set stderr=stderr.txt
echo Begin at %time% %date% 1> %stdout% 2> %stderr%
ieclient %* 1>> %stdout% 2>> %stderr%

for /f %I in ('%stdout%') do set test=%I&gotocontinue
:continue
echo The variable TEST is set to %test%

Not sure what you are actually trying to do though.  Please post again ... and more points... for more info.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question