/usr/share/gridengine/util/sgeremoterun is in gridengine-common 8.1.9+dfsg-7build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | #!/bin/sh
#
# run command remotely by using "rsh" or "ssh"
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
PATH=/bin:/usr/bin:/usr/local/bin
# "$SGE_ROOT" and $SGE_CELL (if other than "default") must be set in current
# environment.
#
if [ "$SGE_ROOT" = "" ]; then
echo environment variable \"\$SGE_ROOT\" not set. Exit.
exit 1
fi
if [ "$SGE_ROOT" = "/" ]; then
echo environment variable \"\$SGE_ROOT\" cannot be set to \"/\". Exit.
exit 1
fi
if [ ! -f "$SGE_ROOT/util/arch" ]; then
echo
echo ERROR: The shell script \"$SGE_ROOT/util/arch\" does not exist.
echo Please verify your distribution and restart this script. Exit.
echo
exit 1
fi
if [ ! -f $SGE_ROOT/util/arch_variables ]; then
echo
echo ERROR: Missing shell script \"$SGE_ROOT/util/arch_variables\".
echo Please verify your distribution and restart this script. Exit.
echo
exit 1
fi
. $SGE_ROOT/util/arch_variables
get_all_hosts()
{
# have to run on the master host, as we might have
# local spool directories, or BDB spooling
master_host=`cat $SGE_ROOT/$SGE_CELL/common/act_qmaster`
if [ "$HOST" = "" ]; then
HOST=`hostname`
fi
if [ "$master_host" != "$HOST" ]; then
echo "ERROR: sgeremoterun -all has to be called on the master host. Exit." >&2
echo >&2
exit 1
fi
spooling=`grep spooling_method $SGE_ROOT/$SGE_CELL/common/bootstrap | awk '{ print $2 }'`
if [ "$spooling" = "classic" ]; then
qma_spool_dir=`grep qmaster_spool_dir $SGE_ROOT/$SGE_CELL/common/bootstrap | awk '{ print $2 }'`
hosts=`ls $qma_spool_dir/exec_hosts | egrep -v "template|global"`
else
hosts=`$SGE_ROOT/utilbin/$ARCH/spooledit list | grep "EXECHOST" | cut -d : -f 2 | egrep -v "template|global"`
fi
}
if [ $# -lt 2 -o "$1" = "-h" -o "$1" = "-help" ]; then
echo
echo "Remotely execute commands via \"rsh\" or \"ssh\"."
echo
echo "usage: $0 [-noexec] [-ssh] [-all] [-noqmaster] [host1]... -- command"
echo " -noexec do nothing, just print what would be done"
echo " -ssh uses \"ssh\" instad of \"rsh\""
echo " -sshpath path where ssh is installed of not in $PATH"
echo " -all run command on all execution hosts found in qmaster spool dir."
echo " -noqmaster do not run command on current qmaster host"
echo
exit 1
fi
if [ "$SGE_CELL" = "" ]; then
SGE_CELL=default
export SGE_CELL
fi
noexec=false
cmd=rsh
qmaster=true
CMD=""
hosts=""
done=false
whoseargs="args"
while [ "$1" != "" -a $done = false ]; do
case "$1" in
--)
whoseargs="cmd"
;;
*)
if [ "$whoseargs" = "args" ]; then
case "$1" in
-noexec)
noexec=true
;;
-ssh)
cmd=ssh
;;
-sshpath)
PATH=$PATH:$2
shift
;;
-all)
get_all_hosts
;;
-noqmaster)
qmaster=false
;;
-*)
echo "unknown option: $1"
exit 1
;;
*)
hosts="$hosts $1"
;;
esac
else
CMD=$*
done=true
fi
;;
esac
shift
done
if [ "$CMD" = "" ]; then
echo No command to execute. Exit.
exit 1
fi
if [ "$hosts" = "" ]; then
echo No hosts given. Exit.
exit 1
fi
act_qmaster=none
if [ $qmaster = false ]; then
if [ -f $SGE_ROOT/$SGE_CELL/common/act_qmaster ]; then
act_qmaster=`cat $SGE_ROOT/$SGE_CELL/common/act_qmaster`
else
echo "File $SGE_ROOT/$SGE_CELL/common/act_qmaster does not exist. Exit."
exit 1
fi
fi
if [ $noexec = true ]; then
echo
echo The command:
echo
echo " % echo \". $SGE_ROOT/$SGE_CELL/common/settings.sh; cd $SGE_ROOT && $CMD\" | $cmd $h /bin/sh"
echo
echo would be executed on the following hosts:
echo
echo " $hosts"
echo
if [ $qmaster = false ]; then
echo The command would not be executed on host
echo
echo " $act_qmaster"
echo
fi
exit 0
fi
for h in $hosts; do
if [ $qmaster = false -a $h = "$act_qmaster" ]; then
echo not executing command on qmaster host \"$act_qmaster\"
else
echo ". $SGE_ROOT/$SGE_CELL/common/settings.sh; cd $SGE_ROOT && $CMD" | $cmd $h /bin/sh
fi
echo ==============================================================================
done
|