# # Original Author: Jeff and Alex # Last Modified By: Jeff and Alex # Last Modified: 1999-09-10 # # Execs the file specified in the run key formdata in the path specified by the # URL. This is potentially a very dangerous script! Be very carefully where you place # this. set filename [lrange [ns_conn urlv $conn] end end] regsub "$filename\$" [ns_url2file [ns_conn url $conn]] {} path set output "$filename
$path" set formdata [ns_conn form $conn] if [string match $formdata ""] { ns_return $conn 200 text/plain "No file specified. To specify file put ?run=filename at end of url, ex. [ns_conn location $conn][ns_conn url $conn]?run=batchfile.bat" return } set file [ns_set get $formdata "run"] if [file exists $path$file] { set output [exec $path$file] ns_return $conn 200 text/plain $output } else { ns_return $conn 200 text/plain "The file '$file' doesn't exist in $path" }