I am having a script which i have set in the debug mode:
set -x
#!/bin/sh
ALLCIRCLS="/var/tmp/release/ALLCIRCLS.txt"
NONRBTIPS="/var/tmp/release/NONRBTIP.txt"
RBTIPS="/var/tmp/release/RBTIPS.txt"
NONRBTIPGNOCIP="/var/tmp/release/NONRBTIPGNOCIP.txt"
NONRBTROOTIP="/var/tmp/release/NONRBTROOTIP.txt"
LOGFILE="/var/tmp/release/log_result.log"
release="/var/tmp/deployment/*"
for IP_ADDRESS in $(cat $NONRBTIPS); do
echo "TEST FOR ${IP_ADDRESS}" >> $LOGFILE
scp -r /var/tmp/deployment/* test@${IP_ADDRESS}:/var/mnt/promptbase/prompts/local_cms >> $LOGFILE
if [ $? -ne 0 ] ; then
echo "Secure copy is failed " >> $LOGFILE
exit 1
else
echo "Secure copy is successfull"
fi
done
As it is in debug mode I am getting output as described below:
+ ALLCIRCLS=/var/tmp/release/ALLCIRCLS.txt
+ NONRBTIPS=/var/tmp/release/NONRBTIP.txt
+ RBTIPS=/var/tmp/release/RBTIPS.txt
+ NONRBTIPGNOCIP=/var/tmp/release/NONRBTIPGNOCIP.txt
+ NONRBTROOTIP=/var/tmp/release/NONRBTROOTIP.txt
+ LOGFILE=/var/tmp/release/log_result.log
+ release='/var/tmp/deployment/*'
++ cat /var/tmp/release/NONRBTIP.txt
+ for IP_ADDRESS in '$(cat $NONRBTIPS)'
+ echo 'TEST FOR 172.19.117.198'
+ scp -r /var/tmp/deployment/ID_MB4_W2JUL19 [email protected]:/var/mnt/promptbase/prompts/local_cms
I would like to keep my terminal clean and print all the debugging of the script in the log file using $LOGFILE
?
#!/bin/sh
) must be the first thing in the file. You should either putset -x
after it, or use#!/bin/sh -x
.