Apendice 2-3 (Trapper.tk)

#!/sw3/common/agent.1.1/binex/bin/agent-tk set machines "" set MyName "" set n [mask new] mask handler $n TrapEvent mask add $n "ANY ANY -tag STOP -handler Stop" mask_replace event $n #----------------------------------------------------------------------- proc TrapEvent {source tag string} { global agent if {$tag == "CREATE"} { } } #----------------------------------------------------------------------- proc Stop {source tag string} { # actions regard to come back o die. # set imagen [append result "davinci/monaLisa.gif"] # set img [image create photo -file $imagen] # append list "files: $files\n" } #----------------------------------------------------------------------- proc who machines { global MyName global agent global home global files global topic set list "" set path "/home/u/raid/vol07/is091892/Give.csh" foreach m $machines { if {[catch "agent_jump $m" result]} { append list "$m:\nunable to JUMP to this machine ($result)\n\n" } else { agent_name $MyName agent_event "$home Search_Agent" ARRIVAL $MyName if {[catch "exec /home/u/raid/vol07/is091892/dir.csh" result]} { append list "<########## $m ##########>\n$result\n\n" } else { append list "<########## $m ##########>\n\n" foreach node $files { if {[lindex [split $node :] 0] == $m} { append list "Document #[lindex [split $node :] 1]\n" append list "[exec $path $topic [lindex [split $node :] 1]] \n\n"} } } } } return $list } #----------------------------------------------------------------------- if {[catch {agent_begin}]} { return -code error "ERROR: unable to register on $agent(actual-server)" } set MyName [lindex $argv 0 ] set machines [lindex $argv 1 ] set topic [lindex $argv 2 ] set files [lindex $argv 3 ] agent_name MyName set home $agent(local-ip) set data [who $machines] agent_jump $home agent_name $MyName main create -name "< Agent: $MyName >" -display $agent(local-server):0 frame .top -relief raised -bd 1 frame .middle -relief raised -bd 1 frame .bot -relief raised -bd 1 pack .top -side top -fill both pack .middle -side top -fill both pack .bot -side bottom -fill both # set img [image create photo -file ~/images/yes.gif] label .img -text pack .img -in .top -side left text .text -relief sunken -bd 2 -yscrollcommand ".scroll set" scrollbar .scroll -command ".text yview" pack .scroll -in .middle -side right -fill y pack .text -in .middle -side left -fill both -expand 1 button .done -text "Destroy myself" -command "set done 1" button .send -text "Send data" -command { agent_event "$agent(local-ip) Search_Agent" DATA $data } pack .done .send -in .bot -side left -expand 1 -padx 3m -pady 2m .text delete 1.0 end .text insert end $data agent_event "$agent(local-ip) Search_Agent" HELLO "hi everybody..." tkwait variable done agent_end exit