Discussion:
How do I run interactive commands
(too old to reply)
T
2022-11-08 01:56:13 UTC
Permalink
Hi All,

I am scratching my head trying to figure out how to
gather information from a RAID controller.

I need to issue the following commands to the controller's
configuration utility:

hptraidconf
query array
exit

In Linux bash programming, there is a way, but I
know of no way to do it with Windows.

Many thanks,
-T
JJ
2022-11-08 12:34:43 UTC
Permalink
Post by T
Hi All,
I am scratching my head trying to figure out how to
gather information from a RAID controller.
I need to issue the following commands to the controller's
hptraidconf
query array
exit
In Linux bash programming, there is a way, but I
know of no way to do it with Windows.
Many thanks,
-T
Try doing it like below.

@echo off
(
echo hptraidconf
echo query array
echo exit
) | "c:\program files\raid mgmt\raid-configurator.exe"
T
2022-11-08 23:00:05 UTC
Permalink
Post by JJ
Post by T
Hi All,
I am scratching my head trying to figure out how to
gather information from a RAID controller.
I need to issue the following commands to the controller's
hptraidconf
query array
exit
In Linux bash programming, there is a way, but I
know of no way to do it with Windows.
Many thanks,
-T
Try doing it like below.
@echo off
(
echo hptraidconf
echo query array
echo exit
) | "c:\program files\raid mgmt\raid-configurator.exe"
Thank you JJ!

I wrote this up as a Keeper:


How to run interactive programs from batch

echo inside (), then pipe to your command


Example

<DiskPart.ListVol.bat>

@echo off
(
echo List volume
echo exit
) | C:\Windows\System32\diskpart.exe

</DiskPart.ListVol.bat>


K:\Windows\NtUtil>DiskPart.ListVol.bat

Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: KVM-W7

DISKPART>
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- ---------
--------
Volume 0 D CD-ROM 0 B No Media
Volume 1 E virtio-win- CDFS CD-ROM 301 MB Healthy
Volume 2 System Rese NTFS Partition 100 MB Healthy
System
Volume 3 C DRIVE_C NTFS Partition 39 GB Healthy Boot
Volume 4 H BACKUP NTFS Partition 38 MB Healthy
Volume 5 M KVM-W7-Back NTFS Partition 2014 MB Healthy

DISKPART>
Leaving DiskPart...
T
2022-11-08 23:28:16 UTC
Permalink
Unfortunately my command won't take pipes too well, but
they have a way off accepting the command on the command
line.

You prefixing you command with
"hptraidconf -u RAID -p hpt"

For example: hptraidconf -u RAID -p hpt query devices



C:\NtUtil>"C:\Program Files (x86)\HighPoint Technologies, Inc\HighPoint
RAID Management\Service\hptraidconf.exe" -u RAID -p hpt query devices

ID Capacity MaxFree Flag Status ModelNumber
JJ
2022-11-09 00:53:33 UTC
Permalink
Post by T
Unfortunately my command won't take pipes too well, but
they have a way off accepting the command on the command
line.
You prefixing you command with
"hptraidconf -u RAID -p hpt"
For example: hptraidconf -u RAID -p hpt query devices
C:\NtUtil>"C:\Program Files (x86)\HighPoint Technologies, Inc\HighPoint
RAID Management\Service\hptraidconf.exe" -u RAID -p hpt query devices
ID Capacity MaxFree Flag Status ModelNumber
------------------------------------------------------------------------------
1/E1/1 1000.20 0 SINGLE LEGACY Samsung SSD 980 1TB
1/E1/2 1000.20 0 SINGLE LEGACY Samsung SSD 980 1TB
------------------------------------------------------------------------------
Some CLI tool clears the input buffer at program startup. In this case, try
doing it like below.

@echo off
(
timeout 2 > nul
echo query array
echo exit
) | hptraidconf

The timeout duration should be long enough to postpone the input injection
so that, it will be injected after the tool actually starts asking for an
input.

If the CLI tool clears the input buffer each time it ask for an input, then
there need to be a delay before each command. e.g.

@echo off
(
timeout 2 > nul
echo query array
timeout 2 > nul
echo exit
) | hptraidconf

In above case, the second timeout duration should include the time need for
the `query array` command to complete. i.e. if that command took 2 seconds
to complete, then the second timeout duration should be at least 3 seconds.

If nothing with piping works, it means that the CLI tool ask for the input
directly from the keyboard rather than the standard input. In this case, a
tool such as Windows Script Host (VBScript/JScript), or Autohotkey should be
used to generate keyboard key presses.
T
2022-11-09 08:42:19 UTC
Permalink
Post by JJ
Post by T
Unfortunately my command won't take pipes too well, but
they have a way off accepting the command on the command
line.
You prefixing you command with
"hptraidconf -u RAID -p hpt"
For example: hptraidconf -u RAID -p hpt query devices
C:\NtUtil>"C:\Program Files (x86)\HighPoint Technologies, Inc\HighPoint
RAID Management\Service\hptraidconf.exe" -u RAID -p hpt query devices
ID Capacity MaxFree Flag Status ModelNumber
------------------------------------------------------------------------------
1/E1/1 1000.20 0 SINGLE LEGACY Samsung SSD 980 1TB
1/E1/2 1000.20 0 SINGLE LEGACY Samsung SSD 980 1TB
------------------------------------------------------------------------------
Some CLI tool clears the input buffer at program startup. In this case, try
doing it like below.
@echo off
(
timeout 2 > nul
echo query array
echo exit
) | hptraidconf
The timeout duration should be long enough to postpone the input injection
so that, it will be injected after the tool actually starts asking for an
input.
If the CLI tool clears the input buffer each time it ask for an input, then
there need to be a delay before each command. e.g.
@echo off
(
timeout 2 > nul
echo query array
timeout 2 > nul
echo exit
) | hptraidconf
In above case, the second timeout duration should include the time need for
the `query array` command to complete. i.e. if that command took 2 seconds
to complete, then the second timeout duration should be at least 3 seconds.
If nothing with piping works, it means that the CLI tool ask for the input
directly from the keyboard rather than the standard input. In this case, a
tool such as Windows Script Host (VBScript/JScript), or Autohotkey should be
used to generate keyboard key presses.
Bugger!


@echo off

(
timeout 10 > nul
echo query array
timeout 10 > nul
echo exit

) | "C:\Program Files (x86)\HighPoint Technologies, Inc\HighPoint RAID
Management\Service\hptraidconf.exe"

The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
Kerr-Mudd, John
2022-11-09 10:42:57 UTC
Permalink
On Tue, 8 Nov 2022 15:00:05 -0800
[piped commands]]
Post by T
Thank you JJ!
How to run interactive programs from batch
echo inside (), then pipe to your command
Example
<DiskPart.ListVol.bat>
@echo off
(
echo List volume
echo exit
) | C:\Windows\System32\diskpart.exe
</DiskPart.ListVol.bat>
Thanks.
--
Bah, and indeed Humbug.
Loading...