Detect drive by label

nnCron and nnCron LITE discussion

Detect drive by label

Postby jpb2001 » Mon, 05 Jun 2006, 23:01

I want to have a Shutdown job that only starts if a certain drive label is available rather than having to specify a drive letter.

Is this possible in nncron? I have found the WatchDrive events but ideally would like to use labels.

Thanks for any help.
JB
jpb2001
 
Posts: 4
Joined: Mon, 05 Jun 2006, 22:58

Postby Nicholas_Nemtsev » Wed, 07 Jun 2006, 17:24

Use new version of system.spf
I have added word GET-VOL-LABEL.
Example:
Code: Select all
#( show-vol-name
NoActive
Action:
    MSG: "%CHAR E GET-VOL-NAME%"
)#

#( test-vol-name
Rule: [CHAR] E GET-VOL-NAME S" D1V3" COMPARE 0= ;
Action:
    MSG: "The drive D1V3 is present"
)#
Nicholas Nemtsev
User avatar
Nicholas_Nemtsev
Site Admin
 
Posts: 857
Joined: Thu, 01 Jul 2004, 22:25
Location: Псков

Postby LuckMan212 » Tue, 04 Jul 2006, 08:49

this is nice but is there any way to tell if a drive is attached to the system by specifying its volume label without also knowing the drive letter?

for example, I would like to have some auto-backup task that runs whenever I attach my USB memory drive, but sometimes I use different USB ports and a different drive letter gets assigned. The drive is always called "RESQ" so I would like to make a task like:
Code: Select all
#( auto_backup
Rule: GET-VOL-NAME S" RESQ" EXIST? ;
Action:
  \ do my backup....
)#

smth like that.. would be useful. is it possible? :wink:
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby Nicholas_Nemtsev » Tue, 04 Jul 2006, 16:45

Code: Select all
#( vol-exist
NoActive
: VOL-EXIST? ( a u -- letter/0)
     [CHAR] Z 1+ [CHAR] C
     DO I GET-VOL-NAME 2OVER COMPARE 0=
           IF 2DROP I UNLOOP EXIT THEN
     LOOP
     2DROP 0
;
Action:
    S" D1V2" VOL-EXIST? ?DUP
    IF SP@ 1 MsgBox DROP THEN
)#
Nicholas Nemtsev
User avatar
Nicholas_Nemtsev
Site Admin
 
Posts: 857
Joined: Thu, 01 Jul 2004, 22:25
Location: Псков

Postby LuckMan212 » Wed, 05 Jul 2006, 00:50

thank you Nicholas, this is excellent :lol:
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 0 guests

cron