--- alx-src/branches/alx-web-060/include/common-functions.php 2011/05/09 21:58:32 2021 +++ alx-src/branches/alx-web-060/include/common-functions.php 2011/05/09 22:13:37 2022 @@ -1,8 +1,9 @@ "; - - exec($sshcmd.' '.$ip.' "source /etc/profile;'.$cmd.'"', $outarr, $err); - if ($verbose == 1) + # check if the client is online + passthru($pingcmd.' '.$ip.' &> /dev/null && exit 0 || exit 1', $retval); + if ($retval == 0) { - echo "err: '".$err."'
"; - foreach( $outarr as $i ) + if ($verbose == 1) echo "sshcmd: '".$sshcmd."'
"; + + # exec the cmd + exec($sshcmd.' '.$ip.' "source /etc/profile;'.$cmd.'"', $cmdout, $err); + if ($verbose == 1) { - echo "outarr: '".$i."'
"; + echo "err: '".$err."'
"; + foreach( $cmdout as $i ) + { + echo "cmdout: '".$i."'
"; + } } - } - if($err != 0) echo ''; - else if ($verbose == 1) echo ''; - - return $outarr; + if($err != 0) if ($failure == 1) echo ''; + else if ($verbose == 1) echo ''; + } + else if ($failure == 1) echo ''; } + + # return the output of $cmd + return $cmdout; } ?>