Solved

Collecting stdout into DOS variable

Posted on 2006-07-01
4
1,422 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
[X]
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
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

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…
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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