File: alpr.tcl

package info (click to toggle)
tkchooser 2.0652-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 432 kB
  • ctags: 272
  • sloc: tcl: 3,344; makefile: 76; sh: 13
file content (69 lines) | stat: -rwxr-xr-x 1,806 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/tclsh
## This script is a filtering wrapper to pap. All commandline arguments
## except filenames are passed directly to pap. Each file is filtered
## through the default filter or the user's defined tkchooser filter.
## The global tkchooser filter is not supported yet - I'm falling asleep
## at the keyboard.
## Ethan Gold <etgold@cs.columbia.edu> 3/22/99
## This script is part of tkchooser. Tkchooser's license terms apply.

## appletalk location
set libdir "/usr/lib/tkchooser"

if {[file readable "/etc/chooser.cfg"]} {
    source "/etc/chooser.cfg"
} elseif {[file readable "$libdir/chooser.cfg"]} {
    source "$libdir/chooser.cfg"
} else {
    puts "$libdir/chooser.cfg unreadable. exiting."
    exit
}

set pap "pap"

## config file locations
set filter "enscript -Z -p -"
if ![info exists env(HOME)] {
    set env(HOME) "~"
}

## read the filter or use enscript
## open user file if it exists
if [file readable $env(HOME)/printfilter] {
    set filtfd [open $env(HOME)/printfilter r]
    gets $filtfd filter
    close $filtfd
    unset filtfd
}

## separate the files and arguments
## the assumption is that arguments won't also happen
## to be the names of readable files in the filesystem
set notfiles ""
foreach arg $argv {
    if {[file readable $arg]} {
	lappend files $arg
    } else {lappend notfiles $arg}
}

set cmdstring "$filter | $pap $notfiles"

## filter and print each file
if [info exists files] {
    foreach file $files {
	#puts "eval exec cat $file | $cmdstring"
	catch {eval exec cat $file | $filter | $pap $notfiles} errors
	#puts $errors
    }
} else {
    ## otherwise read from stdin
    #puts "|$cmdstring"
    eval set pipefd [open "|$cmdstring" r+]
    while {[gets stdin line] >= 0} {
	puts $pipefd $line
	#puts $line
    }
    catch close $pipefd
}

exit