From 0d11516d2540f1f3a5fe6d3a5e5e1b94b5350851 Mon Sep 17 00:00:00 2001 From: miljenko Date: Mon, 17 Dec 2007 14:12:00 +0000 Subject: [PATCH] Repository cleanup, vimageShellServer.sh, start_servers.sh and exec_server.sh removed. (They were used for "remote execution"). Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- exec_server.tcl | 118 ------------------------------------------- start_servers.sh | 15 ------ vimageShellServer.sh | 20 -------- 3 files changed, 153 deletions(-) delete mode 100755 exec_server.tcl delete mode 100755 start_servers.sh delete mode 100755 vimageShellServer.sh diff --git a/exec_server.tcl b/exec_server.tcl deleted file mode 100755 index f0ceb4f..0000000 --- a/exec_server.tcl +++ /dev/null @@ -1,118 +0,0 @@ -# $Id: exec_server.tcl,v 1.6 2007/07/19 03:14:13 marko Exp $ -#! /usr/local/bin/tclsh8.4 - -####### -# Script should be called with at least one argument: port number -# The second (optional) argument is used for debugging -# ./exec_server port_number [debug] -# ./exec_server 2547 - -if { [llength $argv] == 0 || ! [string is integer [lindex $argv 0]] } { - puts stderr \ - "Script should be called with at least one argument, server's port number:\ - \n ./exec_server 2547 \[debug\]" - exit 2 -} - -set debug_output false -if { [llength $argv] == 2 && [lindex $argv 1] == "debug" } { - set debug_output true -} - -set spremam_conf_fajl false - - -####### -# Exec_Accept -- Accept a connection from a new client. -# This is called after a new socket connection has been created by Tcl. -# -# Arguments: -# sock The new socket connection to the client -# addr The client's IP address -# port The client's port number - -proc ExecAccept {sock addr port} { - global client - - # Record the client's information - puts "Accept $sock from $addr port $port" - set client(addr,$sock) [list $addr $port] - - fconfigure $sock -buffering full - - # Set up a callback for when the client sends data - fileevent $sock readable [list Exec_command $sock] -} - -####### -# Exec_command -- -# This procedure is called when the server can read data from the client -# -# Arguments: -# sock The socket connection to the client - -proc Exec_command {sock} { - global client server_port debug_output fileId spremam_conf_fajl - - # Check end of file or abnormal connection drop, - # then send result of exec command back to the client. - - if {[eof $sock] || [catch {gets $sock line}]} { - close $sock - puts "Close $client(addr,$sock)" - unset client(addr,$sock) - return - } - - if { $debug_output } { puts "$server_port/K: >$line<" } - - if { $line == "Kraj" } { - puts "Kraj rada." - puts $sock "Kraj" - close $sock - exit 0 - } - - - if {$spremam_conf_fajl} { - if { $line == "close_conf_file" } { - if { $debug_output} { puts "Zatvaram conf fajl" } - close $fileId - set spremam_conf_fajl false - puts $sock "Kraj" - } else { - catch {puts $fileId $line} odg - if { $debug_output && ($odg != "") } { - puts "$server_port/puts greska: $odg" - } - } - } else { - if { [lindex $line 0] == "create_conf_file" } { - set conf_fajl [lindex $line 1] - if { $debug_output} { puts "Spremam conf fajl: $conf_fajl" } - set fileId [open "$conf_fajl" w] - ;# dodati provjeru!!! - set spremam_conf_fajl true - - } else { - if { [llength $line] == 0 } { return} - catch {eval exec $line} odg - if { $debug_output } { puts "$server_port/O: $odg" } - puts $sock $odg - } - - puts $sock "Kraj" - } - catch {flush $sock} rez - if { $rez != "" } { - puts "Socket closed on remote.\n$rez" - } -} - -####### -# Open the server listening socket and enter the Tcl event loop - -set server_port [lindex $argv 0] -set s [socket -server ExecAccept $server_port] -vwait forever - diff --git a/start_servers.sh b/start_servers.sh deleted file mode 100755 index 0bbc48c..0000000 --- a/start_servers.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh - -# 199 v0 I 0:00.81 /usr/local/bin/tclsh8.4 ./exec_2server.tcl -# 200 v0 I 0:03.23 /usr/local/bin/tclsh8.4 ./exec_server.tcl -# 992 v0 I 0:00.01 nc -l -p 1235 -pids=`ps -ax | grep "/usr/local/bin/tclsh8.4 ./exec_" | awk '{print $1}'` - -if test "a$pids" != "a" -then - kill -9 $pids -fi - -./exec_server.tcl 2547 debug & -./exec_server.tcl 2548 & - diff --git a/vimageShellServer.sh b/vimageShellServer.sh deleted file mode 100755 index 0891cce..0000000 --- a/vimageShellServer.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh - -# $1 ... vimage_name (eg. e0_n12) -# $2 ... port (eg. 1234) -# $3 ... command (e.g. /usr/local/bin/bash) - -scriptname=/tmp/vimage_shell.$$.sh - -echo "#! /bin/sh" > $scriptname -#echo "vimage $1 $3 -i" >> $scriptname -if [ "$3" = vtysh ] - then - echo "vimage $1 $3 " >> $scriptname - else - echo "vimage $1 $3 -i " >> $scriptname -fi -chmod +x $scriptname -nc -l -p $2 -e $scriptname -rm $scriptname - -- 2.39.5