#!/usr/bin/expect -- # (eeman "expect" 491) # (find-fline "/usr/lib/tcl8.0/") # (find-fline "/usr/doc/tk8.0/") # (find-vldifile "tcl8.0-dev.list") # (eeman "tclvars") # (eeman "tclsh" "VARIABLES") # (eeman "3tcl expr") # (eeman "3tcl proc") # (eeman "3tcl lrange") # (eeman "3tcl foreach") # Note que o ftp nĈo precisa de login e password pras m quinas # listadas no .netrc. # # Example: # ~/EXPECT/anonftp ftp.debian.org 'cd debian' dir # ~/EXPECT/anonftp ftp.debian.org 'cd debian' dir quit if {$argc==0} { send_error "Usage: anontfp \[-q\] machine \[command \[command ...\]\]\n" exit 1 } set timeout -1 if {[lindex $argv 0]=="-q"} { log_user 0; set argv [lrange $argv 1 end] } spawn ftp [lindex $argv 0] while 1 { expect { -re "\nName.*:" { send "anonymous\n" } "\nPassword:" { send "edrx@inx.com.br\n" } "\nftp>" { break } } } proc ftpdo {args} { send "[concat $args]\n" expect "\nftp>" {} eof {exit} } ftpdo hash on ftpdo prompt off if {![log_user]} { send_user "ftp>"; log_user 1 } foreach command [lrange $argv 1 end] { eval ftpdo $command } interact