Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'open3'
- path = ARGV[0]
- name = ARGV[1]
- by_path = {}
- by_adapter = {}
- Dir.glob('/dev/dvb/*').sort.each do |a|
- Open3.popen3("udevadm test-builtin path_id $(udevadm info -q path -n #{a}/dvr0)") do |stdin, stdout, stderr, wait_thr|
- path_id = nil
- stdout.readlines.each do |line|
- line.strip!
- m = /^ID_PATH=(.*)$/.match(line)
- path_id = m[1] if m
- end
- if path_id
- by_path[path_id] = 0 unless by_path.has_key?(path_id)
- by_adapter[a] = "#{path_id};#{by_path[path_id]}"
- by_path[path_id] += 1
- end
- end
- end
- id = by_adapter[path]
- if id
- puts id
- else
- exit(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement