Page 1 of 1

How to utlize usr commands in a bat file

Posted: Jun 1st, 2021, 1:05 am
by jeffshead
First, I want to use USR CLI to determine if a particular drive is mounted and ready to use.

I know I can use the following command to list the available drives:

Code: Select all

usr.exe list -s
What is the code that I need to add to a batch file that will search the output that that command returns?

Example of what I want to accomplish:

Code: Select all

if usr.exe list -s contains 726060ALE610 (
set diskStatus=readyToUse
)

Re: How to utlize usr commands in a bat file

Posted: Jun 1st, 2021, 2:30 pm
by Igor
Hello jeffshead,
At the moment there's no "status" command in the list and it's a bit difficult to parse the output of the "list" command since the device there can be either in a normal status or in safely removed status.

Code: Select all

1. PLDS DVD-RW DS8A8SH (E:)

Code: Select all

1. PLDS DVD-RW DS8A8SH (E:)    (safely removed)
So you need to iterate through all the lines (devices) given by the "list" command and check that the found device doesn't have "(safely removed)" or "(disabled)" char sequences in the end. It seems that's possible to do using FOR dos directive, but I cannot give you an exact code to do your task since it's out of scope of my knowledge.

We may consider adding the "status" command, thiugh. What's your final purpose, why do you need to check if the drive is ready or no?

Re: How to utlize usr commands in a bat file

Posted: Jun 2nd, 2021, 2:40 am
by jeffshead
Hi Igor,

I am trying to set up a backup job. I have a USB drive plugged into a remote IP PDU. The drive stays powered off. When the backup job starts, it will run a script that turns the power on and mounts the USB drive. I need to make sure the drive is mounted and ready to use before writing to it.

When the backup is finished, another script is ran that ejects the USB drive and turns the power off.

So I'm trying to figure out the best way to accomplish this.

Below is what I've come up with so far but it doesn't check for "(safely removed)" or "(disabled)":

Code: Select all

usr.exe list -s | findstr %drvMdl%
if %errorlevel% == 0 (
  set drvStatus=ready
) else (
  set drvStatus=notFound
)
After testing with three different HDD enclosures/docking stations, only one of them populated the list with the HDD model #. The others populate the list with:
1. Dual Drive Dock 1 SCSI Disk Device (D:)
and
2. Avastor HDX Pro SCSI Disk Device (F:)

Re: How to utlize usr commands in a bat file

Posted: Jun 2nd, 2021, 10:43 am
by Igor
jeffshead,
I'd suggest to test the status of the disk with something else rather than our tool. If you know the drive letter you can use lots of dos commands. For example you can use mountvol command:

Code: Select all

mountvol x: /L
It returns 0 error if the drive is ready and 1 if it's not there.