2

I'm running the below script on RHEL 7.9 and after connecting to the remote machine and execing pbrun, the last login message is getting displayed and sometimes it interferes with the command which is forcing me to do many more steps than necessary and it's just downright frustrating.

As I stated in the subject, I have tried this with "ssh -q" as well as with "ssh -q" AND a .hushlogin file in both my home directory as well as root's home.

I'm sure it has to do with the switching of users, but I can't figure out how to get rid of the last login message. **** MODIFYING SYSTEM FILES IS OUT OF THE QUESTION ****

There appears to be another issue when trying to remove a file, it's the "CASCU050E Failed to send data (Reason=[send failed], Rc=[111])." errors in the below output.

Any help greatly appreciated!

Thanks

Here's the script:


if [ "$#" -ne 2 ]; then
    echo "You must enter exactly 2 command line arguments"
    echo "argument 1 = file containing all hosts to test, one fqdn per line."
    echo "argument 2 = full path to output file."
    exit 1
fi

echo 'Please enter your AD passord for API authentication'
echo -n "Password: "
read -s passy
echo ""

sshpass="sshpass -p$passy ssh -q -oStrictHostKeyChecking=no"
scppass="sshpass -p$passy scp -r -q -oStrictHostKeyChecking=no"
hosts=$(cat $1)

IAM=$(whoami)

echo "*** Moving existing /tmp/perf directories out of the way. ***"
for HOST in $hosts; do
        if ($sshpass $HOST ps waux | grep run-fio-tests | grep -v grep >/dev/null 2>&1)
        then
                echo "*** fio test is currently running on host $HOST, STOPPING THE FIO RUN. ***"
                break
        fi

#####
#Tried with the two following lines uncommented, no change in behavior.
#####
#        $sshpass $HOST "touch .hushlogin"
#       $sshpass $HOST "echo touch .hushlogin | exec pbrun /bin/su -"
        dirs=$($sshpass $HOST "ls /tmp/| grep -i ^perf" | grep -v .tgz)
        for dir in $dirs; do
                echo "Moving existing /tmp/$dir directory to /tmp/$dir.`date +%Y%m%d-%H%M`.tgz on $HOST"
                $sshpass $HOST "tar czf /tmp/$dir.`date +%Y%m%d-%H%M`.tgz -P /tmp/$dir 2>/dev/null"
                $sshpass $HOST "echo chown -R $IAM /tmp/perf | pbrun /bin/su -"
                $sshpass $HOST "rm -rf /tmp/$dir"
        done
done

for HOST in $hosts; do
        echo "*** Cleaning up on $HOST ***"
        $sshpass $HOST "echo rm -rf /tmp/data/randread-raw-data-5G  /tmp/data/seqread-raw-data-32G  /tmp/data/seqwrite-raw-data-5G | exec pbrun /bin/su -"
        $sshpass $HOST "echo rm -rf /tmp/RUNFIO.sh | exec pbrun /bin/su -"
done

Here are the errors i'm getting:

Please enter your AD passord for API authentication
Password: 
*** Moving existing /tmp/perf directories out of the way. ***
Last login: Fri Aug  6 22:51:55 MST 2021
Moving existing /tmp/perf directory to /tmp/perf.20210806-2255.tgz on host1.acme.com
Last login: Fri Aug  6 22:55:38 MST 2021
*** End Moving old perfs. ***
*** Cleaning up on host1.acme.com ***
CASCU050E Failed to send data (Reason=[send failed], Rc=[111]).
CASCU050E Failed to send data (Reason=[send failed], Rc=[111]).
CASCU050E Failed to send data (Reason=[send failed], Rc=[111]).
CASCU050E Failed to send data (Reason=[send failed], Rc=[111]).
CASCU050E Failed to send data (Reason=[send failed], Rc=[111]).
Last login: Fri Aug  6 22:55:45 MST 2021
tom
  • 21
  • 1

0 Answers0