Index: openacs-4/packages/acs-tcl/tcl/proxy-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/proxy-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-tcl/tcl/proxy-procs.tcl 27 Oct 2014 16:40:07 -0000 1.5 +++ openacs-4/packages/acs-tcl/tcl/proxy-procs.tcl 7 Aug 2017 23:47:59 -0000 1.6 @@ -1,5 +1,4 @@ -# packages/acs-tcl/tcl/proxy-procs.tcl - +# packages/acs-tcl/tcl/proxy-procs.tcl ad_library { Proxy procs @@ -9,30 +8,54 @@ @cvs-id $Id$ } -# First check that ns_proxy is configured -if {![catch {set handler [ns_proxy get exec_proxy]}]} { - ns_proxy release $handler +# +# First check if ns_proxy is available +# +if {![catch {ns_proxy configure ExecPool -maxruns 0}]} { namespace eval proxy {} ad_proc -public proxy::exec { - {-call} + {-call} + {-cd} } { - Execute the statement in a proxy instead of normal exec - - @param call Call which is passed to the "exec" command + Execute the statement in a proxy instead of normal exec + + @param call Call which is passed to the "exec" command (required) + @param cd change to the given directory before executing the command } { - set handle [ns_proxy get exec_proxy] - with_finally -code { - set return_string [ns_proxy eval $handle "exec $call"] - } -finally { - ns_proxy release $handle - } - return $return_string + set handle [ns_proxy get ExecPool] + with_finally -code { + if {[info exists cd]} { + # + # We were requested to switch to a different + # directory. Remember the old directory before + # switching to the new one. + # + set pwd [ns_proxy eval $handle pwd] + ns_proxy eval $handle [list cd $cd] + } + set return_string [ns_proxy eval $handle [list ::exec {*}$call]] + } -finally { + if {[info exists pwd]} { + # + # Switch back to the previous directory. + # + ns_proxy eval $handle [list cd $pwd] + } + ns_proxy release $handle + } + return $return_string } # Now rename exec; protect cases, where file is loaded multiple times if {[info commands ::real_exec] eq ""} {rename exec real_exec} ad_proc exec {args} {This is the wrapped version of exec} {proxy::exec -call $args} } + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: