Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8300443
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类:

2009-03-22 13:19:58

tcl带的lib里面有一个叫做ftpd的库,可以用来做ftp服务器。在mandriva环境下进行实验,首先安装tcl,然后通过urpmi安装tcllib库,之后,引用package require ftpd即可。
下面是测试的例子:

#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

# FTP daemon

# This ftpd runs on port 7777, uses /tmp as root dir and does not do
# any authentication at all. IOW, do not run this server for longer
# periods of time or you create a security hole on your machine. This
# server is strictly for short testing the implementation of the ftp
# module over short periods of time.

#package require Tcl 8.3
package require ftpd
package require log

proc bgerror {args} {
    global errorInfo
    puts stderr "bgerror: [join $args]"
    puts stderr $errorInfo
}

proc ftplog {level text} {
    if {[string equal $level note]} {set level notice}
    log::log $level $text
}

proc noauth {args} {
    return 1
}
proc fakefs {cmd path args} {
    # Use the standard unix fs, i.e. "::ftpd::fsFile::fs", but rewrite the incoming path
    # to stay in the /tmp directory.

    set path [file join / tmp [file tail $path]]
    eval [linsert $args 0 ::ftpd::fsFile::fs $cmd $path]
}

::ftpd::config -logCmd ftplog -authUsrCmd noauth -authFileCmd noauth -fsCmd fakefs
set ::ftpd::port 7777 ; # Listen on user port

::ftpd::server
vwait forever

在客户端可以通过ftp 127.0.0.1 7777来进行测试。
阅读(3278) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-03-24 15:33:16

没用过tcl ..开始还以为是某知名品牌.汗