Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

redirect to variable

1 view
Skip to first unread message

Vic....@xspam.p0.f167.n250.z2.fidonet.org

unread,
Feb 12, 2001, 1:54:32 AM2/12/01
to
How can I redirect the output of a command to a variable?

I am wanting to redirect the output of the VOL command to a variable? More
specifically I want to extract just the serial number part of the VOL output
and redirect it to a variable. Then I can test this variable as required.

My 4dos has no way to check disk serial numbers. A function such as %_SNUM[A:]
which returned the serial number of drive A: would be handy.

I've been shown a few ideas in the Batpower echo, but it's a pity 4dos doesn't
have the ability built in to check disk serial numbers.

Rgds, Vic


--- GoldED/386 2.50+43UK1
* Origin: The Bates Motel! Bolton, UK. (2:250/167)

Ian

unread,
Feb 13, 2001, 8:58:26 AM2/13/01
to

<Vic....@xspam.p0.f167.n250.z2.fidonet.org> wrote in message
news:30bdde...@mach2.v-wave.com...
> ArtId: 3768


>
>
> How can I redirect the output of a command to a variable?
>
> I am wanting to redirect the output of the VOL command to a variable? More
> specifically I want to extract just the serial number part of the VOL
output

vol>xtempx.txt
set vol=%@word[9,%@line[xtempx.txt,0]]
echo "%vol"
del /z /Q xtempx.txt


--

- Cho...@Gundam.Com -
- ian...@libero.it -


Vincent Fatica

unread,
Feb 13, 2001, 11:10:14 AM2/13/01
to
On 12 Feb 2001 06:54:32 GMT, Vic....@xspam.p0.f167.n250.z2.fidonet.org
wrote:

>How can I redirect the output of a command to a variable?
>
>I am wanting to redirect the output of the VOL command to a variable? More
>specifically I want to extract just the serial number part of the VOL output
>and redirect it to a variable. Then I can test this variable as required.

set volumeid=%@word[9,%@execstr[vol]]

- Vince

Jochen Schaar

unread,
Feb 13, 2001, 12:18:42 PM2/13/01
to

<Vic....@xspam.p0.f167.n250.z2.fidonet.org> wrote:

> How can I redirect the output of a command to a variable?
>
> I am wanting to redirect the output of the VOL command to a variable? More
> specifically I want to extract just the serial number part of the VOL output
> and redirect it to a variable. Then I can test this variable as required.

Try it this way, Vic:

vol a: | input %%sn
iff %@index[%sn,serial] gt 0 then
set sn=%@word[-0,%sn]
else
set sn=0
endiff
echo Serial number is %sn

Jochen


Klaus Meinhard

unread,
Feb 14, 2001, 3:34:06 AM2/14/01
to
Vic,

> How can I redirect the output of a command to a variable?

> I've been shown a few ideas in the Batpower echo, but it's a pity


4dos doesn't
> have the ability built in to check disk serial numbers.

??? There are few abilities (besides getting the programmer a cup of
coffee) that 4DOS does NOT have. As it is, A few ideas and threads
came together and I have just finished a little (4x)btm for displaying
and changing the serial number:

:: XSERIAL.BTM Change a diskette's serial number Version 2.0
::
:: by Klaus Meinhard
:: Brahmsstr. 12
:: G 26842 Ostrhauderfehn
:: Germany
::
:: (Debug-Code by Horst Schäfer)
::
:: Commandline use with 4 2-digit (hex) numbers,
:: eg.: XSERIAL 12 34 AB EF
:: to get Serial-No. 1234:ABEF


@echo off
*setlocal
*unalias *

if %@index[%&,?] ge 0 (gosub USAGE %+ goto END)

gosub SCREEN
gosub DRV_TST
gosub OLD_SER
set inp=%&
if "%inp" eq "" gosub INP_SER
gosub ERR_CHK
gosub DO_IT
gosub NEW_SER

:END
quit

:DRV_TST
on error (scrput 12 6 bri whi on red ` Disk missing, not formatted
or write protected. `%+ goto END)
set file=%@UNIQUE[a:\]
echo. >>%file
del %file /q
on error
return

:OLD_SER
set sernum=%@word[9,%@execstr[vol a:]]
if "%sernum" eq "" set sernum=-No serial no.-
scrput 6 7 bri whi on blu Old serial no.: %sernum
return

:INP_SER
scrput 12 7 bri blu on blu Enter 4 hex groups: 01 23 AB EF (0 - F)
screen 11 7
input /x/l11 New Serial number : %%inp
return

:ERR_CHK
iff %@words[%inp] == 4 then
do n=0 to 3
set w%n=%@word[%n,%inp]
iff %@convert[16,10,%[W%n]] gt 255 then
set bg=red %+ gosub CLEAN
scrput 12 6 bri whi on red ` `Not a valid serial: %inp
goto END
endiff
enddo
elseiff "%inp" ne "" then
set bg=red %+ gosub CLEAN
scrput 12 6 bri whi on red ` `Wrong parameter number:
%@words[%inp]
goto END
else
set bg=blu %+ gosub CLEAN
scrput 12 6 bri whi on blu ` `Done!
goto END
endiff
return

:DO_IT
Keystack "L100 0 0 1" enter "e126 29 %w3 %w2 %w1 %w0" %=
enter "W100 0 0 1" enter "Q" enter
debug > nul
set bg=blu %+ gosub CLEAN
scrput 12 6 bri whi on blu ` `Done!

return

:NEW_SER
dir a: |ffind /C/K/M/T"Serial number is" | input %%sernum
set sernum=%@word[9,%sernum]
scrput 8 7 bri whi on blu New serial no.: %sernum
return

:SCREEN
cls bri whi on blu
drawbox 4 5 13 46 1 bri whi on bri blu
scrput 4 20 bri whi on red ` XSERIAL.BTM `
drawhline 10 5 42 1 bri whi on bri blu
return

:CLEAN
scrput 11 6 %bg on %bg %@repeat[ÿ,40]
scrput 12 6 %bg on %bg %@repeat[ÿ,40]
return

:USAGE

text


XSERIAL.BTM ÄÄÄÄÄÄÄÄ Change diskette serial number

Command Line Syntax:

XSERIAL 12 34 CD EF 4 groups of hex numbers for new serial

XSERIAL Interactive use

XSERIAL /? or -? Syntax (this screen)

endtext

return


--
Viele Grüße, best regards,

*Klaus Meinhard*

Author of the 4XBTM batch collection at

http://www.4xbtm.de


Jasen...@xspam.p42.f531.n640.z3.fidonet.org

unread,
Feb 14, 2001, 8:37:40 AM2/14/01
to
VB> How can I redirect the output of a command to a variable?

set variable=%@execstr[a command]

VB> I am wanting to redirect the output of the VOL command to a
VB> variable? More specifically I want to extract just the serial
VB> number part of the VOL output and redirect it to a variable. Then
VB> I can test this variable as required

set SN=%@instr[10,-9,%@execstr[vol]]

VB> My 4dos has no way to check disk serial numbers. A function such
VB> as %_SNUM[A:] which returned the serial number of drive A: would
VB> be handy

VB> I've been shown a few ideas in the Batpower echo, but it's a pity
VB> 4dos doesn't have the ability built in to check disk serial
VB> numbers

IMO it's big enough already... it's not real hard to check serial numbers.

-=> Bye <=-

---
* Origin: 3 * 17 * 521 / 50 (3:640/531.42)

Jonathan.de....@xspam.p3.f609.n257.z2.fidonet.org

unread,
Feb 15, 2001, 4:17:38 AM2/15/01
to
KM> Keystack "L100 0 0 1" enter "e126 29 %w3 %w2 %w1 %w0" %=
KM> enter "W100 0 0 1" enter "Q" enter
KM> debug > nul

As far as I am aware, all flavours of DEBUG just read their standard input.
There is no need for KEYSTACK. Just use ordinary redirection.

( ECHO L100 0 0 1 %+ ECHO e126 29 %w3 %w2 %w1 %w0 %+ ECHO W100 0 0 1 %+
ECHO Q ) | DEBUG

or even

SET NL=%@char[10]%``
ECHO L100 0 0 1 %NL%e126 29 %w3 %w2 %w1 %w0 %NL%W100 0 0 1 %NL%Q | DEBUG

» JdeBP «

--- FleetStreet 1.22 NR
* Origin: JdeBP's point, using Squish <yuk!> (2:257/609.3)

Klaus Meinhard

unread,
Feb 17, 2001, 3:39:09 AM2/17/01
to
Jonathan,

> As far as I am aware, all flavours of DEBUG just read their standard
input.
> There is no need for KEYSTACK. Just use ordinary redirection.
>
> ( ECHO L100 0 0 1 %+ ECHO e126 29 %w3 %w2 %w1 %w0 %+ ECHO W100 0
0 1 %+
> ECHO Q ) | DEBUG

Get´s the job done, but displays some unwanted chars on screen. You
probably want to redirect output to nul, too.

Jasen...@xspam.p42.f531.n640.z3.fidonet.org

unread,
Feb 17, 2001, 11:25:00 AM2/17/01
to
Hi Jonathan.

JdBP> or even

JdBP> SET NL=%@char[10]%``
JdBP> ECHO L100 0 0 1 %NL%e126 29 %w3 %w2 %w1 %w0 %NL%W100 0 0 1 %NL%Q
JdBP> | DEBUG
[my line break]

or even

ECHO L100 0 0 1 %=re126 29 %w3 %w2 %w1 %w0 %=rW100 0 0 1 %=rQ |DEBUG

as %=r translates to ^M or enter

-=> Bye <=-

---
* Origin: n. syn. netmail address. (3:640/531.42)

Klaus Meinhard

unread,
Feb 18, 2001, 3:47:34 AM2/18/01
to
Jasen,

for use in XSERIAL, I now use your line with a redirection to nul:

> ECHO L100 0 0 1 %=re126 29 %w3 %w2 %w1 %w0 %=rW100 0 0 1 %=rQ |DEBUG

> nul

0 new messages