Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Enable & Disable Devices from command line

Status
Not open for further replies.

gdc2001

Instructor
Sep 10, 2001
24
GB
I have been playing with with nsradmin, enabling and disabling devices.
Does anyone know how to do this direct from the command line?

You would save my life!
 
... with nsradmin.

You can use a "-f input.txt" option with NSRADMIN,
in this file you just has to put nsradmin commands (such as :". type : NSR Device....".
Just like what you would do on the nsradmin prompt, so, in these commands you'll put the "update" command with the appropriate field value.

Hope this helps.
 
Here is an edited version of a rather elaborate script I wrote for some basic device control.

Calling convention:

lc [device] [command] [misc]
device is a 2-char code I associate with a device
/dev/rmt0.1 = i0, /dev/rmt1.1 = i1, and so on
command is a 2/3-char command, I have several, only
implement 2 of them here: on and off
misc is used by some of my other commands

/root/lc
[tt]#!/bin/ksh

# ${1} = device
# ${2} = cmd

QUIT=0

case "${1}" in
"")
DEVICE=/dev/rmt0.1
;;

"i0")
DEVICE=/dev/rmt0.1
;;

"i1")
DEVICE=/dev/rmt1.1
;;

"i2")
DEVICE=/dev/rmt2.1
;;

"i3")
DEVICE=/dev/rmt3.1
;;
*)
exit
;;
esac

case "${2}" in
"")
nsrmm
;;
"on")
case ${1} in
"i1"|"i2"|"i3")
MEDIA="3590"
;;
*)
echo "lc.on: unknown device"
exit
;;
esac
TMP=/tmp/$$
QUERY="name: \"${DEVICE}\"; media type: \"${MEDIA}\""
rm /tmp/${TMP} 2>/dev/null
echo ". ${QUERY}" >> ${TMP}
echo "update enabled: Yes" >> ${TMP}
nsradmin -i ${TMP} >/dev/null
rm ${TMP} 2>/dev/null
;;

"off")
case ${1} in
"i1"|"i2"|"i3")
MEDIA="3590"
;;
*)
echo "lc.on: unknown device"
exit
;;
esac
TMP=/tmp/$$
QUERY="name: \"${DEVICE}\"; media type: \"${MEDIA}\""
rm /tmp/${TMP} 2>/dev/null
echo ". ${QUERY}" >> ${TMP}
echo "update enabled: No" >> ${TMP}
nsradmin -i ${TMP} >/dev/null
rm ${TMP} 2>/dev/null
;;
*)
nsrmm
;;
esac

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top