VirtualBox

Ticket #8363: vbox_check

File vbox_check, 1.9 KB (added by DHughes, 13 years ago)

small rexx utility to check HardDisk entries in .vbox files

Line 
1#! /usr/local/sbin/rexx
2
3/* Change the #! line to point to your rexx/regina interpreter
4 Change vmbase to point to the top level directory where your VM images are saved.
5 This directory and any sub-directories will be scanned for .vbox, .udi, and .vmdk files.
6*/
7
8vmbase = '/VMs/'
9
10
11paths. = 0
12cnt = 0
13
14ADDRESS COMMAND "find" vmbase "-path '*.vdi'" WITH output stem tmp.
15DO i = 1 TO tmp.0
16 cnt = cnt + 1
17 key = tmp.i
18 paths.cnt = key
19 paths.key = 1
20END
21
22ADDRESS COMMAND "find" vmbase "-path '*.vmdk'" WITH output stem tmp.
23DO i = 1 TO tmp.0
24 cnt = cnt + 1
25 key = tmp.i
26 paths.cnt = key
27 paths.key = 1
28END
29
30ADDRESS COMMAND "find" vmbase "-path '*.vbox' -or -path '*.xml'" WITH output stem tmp.
31DO i = 1 TO tmp.0
32 file_in=tmp.i
33 CALL Check_files file_in
34END
35
36SAY '**** unused images ****'
37SAY
38
39DO i = 1 TO cnt
40 key = paths.i
41 IF ( paths.key = 1 ) THEN DO
42 SAY key
43 END
44END
45
46EXIT
47
48/* **** subroutines **** */
49
50Check_files:
51PROCEDURE EXPOSE paths. cnt
52PARSE ARG file_in
53
54machine = file_in
55enihcam = REVERSE(STRIP(machine))
56PARSE VAR enihcam . '/' htap
57path = REVERSE(htap)
58
59CALL STREAM file_in,'c','close'
60DO i = 1 WHILE( LINES(file_in) > 0 )
61 string = LINEIN(file_in)
62 IF ( POS('<HardDisk ',string) > 1 ) THEN DO
63 PARSE VAR string . 'uuid="' uuid '"' . 'location="' location '"' .
64 location = STRIP(location)
65 location = path'/'location
66 IF ( paths.location > 0 ) THEN paths.location = 2
67 ELSE IF ( paths.location = 0 ) THEN DO
68 SAY 'File:' location 'not found.'
69 PARSE VAR location '/' parta '/'partb '/' partc
70 machine = '/'parta'/'partb'/'
71 SAY 'choices FOR' machine 'Are:'
72 DO i = 1 TO cnt
73 key = paths.i
74 IF ( (POS(machine,key) > 0) & (paths.key = 1) ) THEN DO
75 SAY key
76 END
77 END
78 SAY
79 END
80 END
81END
82CALL STREAM file_in,'c','close'
83RETURN

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy