From 00f38dcd2828d39d9016cd23a690e5a9f20fb2c1 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Wed, 14 Jun 2006 00:41:01 +0000 Subject: * rsh.exp (rsh_exec): Handle inp and outp arguments. Use local_exec to run rsh. Return failure if rsh times out. * remote.exp (local_exec): Handle "|& cat" we added when deciding whether to return output. --- lib/remote.exp | 4 ++-- lib/rsh.exp | 31 ++++++++++++++----------------- 2 files changed, 16 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/remote.exp b/lib/remote.exp index 4ccdb6f..4de8900 100644 --- a/lib/remote.exp +++ b/lib/remote.exp @@ -208,8 +208,8 @@ proc local_exec { commandline inp outp timeout } { } else { set status 0 } - verbose "output is $output" - if { $outp == "" } { + verbose "output is $output status $status" + if { $outp == "" || $outp == "|& cat" } { return [list $status $output] } else { return [list $status ""] diff --git a/lib/rsh.exp b/lib/rsh.exp index 1c08788..1a207a8 100644 --- a/lib/rsh.exp +++ b/lib/rsh.exp @@ -223,20 +223,10 @@ proc rsh_upload {desthost srcfile destfile} { # Execute CMD on BOARDNAME. # -proc rsh_exec { boardname cmd args } { - if { [llength $args] > 0 } { - set pargs [lindex $args 0] - if { [llength $args] > 1 } { - set inp [lindex $args 1] - } else { - set inp "" - } - } else { - set pargs "" - set inp "" - } +proc rsh_exec { boardname program pargs inp outp } { + global timeout - verbose "Executing $boardname:$cmd $pargs < $inp" + verbose "Executing $boardname:$program $pargs < $inp" if {![board_info $boardname exists rsh_prog]} { if { [which remsh] != 0 } { @@ -271,13 +261,20 @@ proc rsh_exec { boardname cmd args } { set inp "/dev/null" } - set status [catch "exec cat $inp | $RSH $rsh_useropts $hostname sh -c '$cmd $pargs \\; echo XYZ\\\${?}ZYX' |& cat" output] - verbose "$RSH output is $output" + set ret [local_exec "$RSH $rsh_useropts $hostname sh -c '$program $pargs \\; echo XYZ\\\${?}ZYX'" $inp $outp $timeout] + set status [lindex $ret 0] + set output [lindex $ret 1] + + verbose "$RSH status is $status, output is $output" + # `status' doesn't mean much here other than rsh worked ok. - # What we want is whether $cmd ran ok. + # What we want is whether $program ran ok. Return $status; + # if the program timed out, status will be 1 indicating that + # rsh ran and failed. If rsh fails, we will get FAIL rather + # than UNRESOLVED - this will help the problem be noticed. if { $status != 0 } { regsub "XYZ(\[0-9\]*)ZYX\n?" $output "" output - return [list -1 "$RSH to $boardname failed for $cmd, $output"] + return [list $status "$RSH to $boardname failed for $program, $output"] } regexp "XYZ(\[0-9\]*)ZYX" $output junk status verbose "rsh_exec: status:$status text:$output" 4 -- cgit v1.1