How to utlize usr commands in a bat file

Post Reply
jeffshead
Posts: 2
Joined: Jun 1st, 2021, 12:48 am

How to utlize usr commands in a bat file

Post 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
)
User avatar
Igor
Developer
Posts: 589
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: How to utlize usr commands in a bat file

Post 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?
jeffshead
Posts: 2
Joined: Jun 1st, 2021, 12:48 am

Re: How to utlize usr commands in a bat file

Post 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:)
User avatar
Igor
Developer
Posts: 589
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: How to utlize usr commands in a bat file

Post 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.
Post Reply