File: simpleExamples.tcl

package info (click to toggle)
tclvfs 1.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,240 kB
  • ctags: 416
  • sloc: tcl: 3,670; xml: 2,882; sh: 2,833; ansic: 1,264; makefile: 58
file content (49 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download | duplicates (6)
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
#!/bin/sh
#-*-tcl-*-
# the next line restarts using wish \
exec tclsh "$0" ${1+"$@"}

catch {console show}

puts "(pwd is '[pwd]', file volumes is '[file volumes]')"

package require vfs

package require vfs::zip
package require vfs::urltype
package require vfs::ftp
package require vfs::http
 
puts "Adding ftp:// volume..."
vfs::urltype::Mount ftp
set listing [glob -dir ftp://ftp.tcl.tk/pub *]
puts "ftp.tcl.tk/pub listing"
puts "$listing"
puts "----"
puts "(file volumes is '[file volumes]')"

puts "Adding http:// volume..."
vfs::urltype::Mount http
set fd [open http://sourceforge.net/projects/tcl]
set contents [read $fd] ; close $fd
puts "Contents of <http://sourceforge.net/projects/tcl> web page"
puts [string range $contents 0 100]
puts "(first 100 out of [string length $contents] characters)"
puts "----"
puts "(file volumes is '[file volumes]')"

puts "Mounting ftp://ftp.ucsd.edu/pub/alpha/ ..."
vfs::ftp::Mount ftp://ftp.ucsd.edu/pub/alpha/ localmount
cd localmount ; cd tcl
puts "(pwd is now '[pwd]' which is effectively a transparent link\
  to a remote ftp site)"
puts "Contents of remote directory is:" 
foreach file [glob -nocomplain *] {
    puts "\t$file"
}
puts "sourcing remote file 'vfsTest.tcl', using 'source vfsTest.tcl'"
# This will actually source the contents of a file on the
# remote ftp site (which is now the 'pwd').
source vfsTest.tcl

puts "Done"