Solved

Collecting stdout into DOS variable

Posted on 2006-07-01
4
1,419 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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 outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

778 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