Hi,
I am writing below script for Some Clean Up Activity. In the end of this script you will see wait /bin/sh “/tmp/gs/dd.sh”
As a part of troubleshooting i have found that dd.sh is not getting executed through BigFix but if i manually execute the same dd.sh file by using bash -x /tmp/gs/dd.sh it get executed and working fine.
#!/bin/sh
curl -k ‘https://abc.com’ > {parameter “Error_Folder”}/pass.json
cat {parameter “Error_Folder”}/pass.json | (tr {{ ‘\n’ | tr , ‘\n’ | tr } ‘\n’ | grep “Content” | awk -F’"’ ‘{{print $4}’) > {parameter “Error_Folder”}/pass.txt
end
delete "/tmp/gs/genpass.sh"
move __createfile "/tmp/gs/genpass.sh"
wait /bin/sh “/tmp/gs/genpass.sh”
#!/bin/sh
PASS=$(cat {parameter “Error_Folder”}/pass.txt)
echo “$PASS” > {parameter “Error_Folder”}/abc.txt
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > {parameter “Error_Folder”}/file1.txt
OUTPUT=$(cat {parameter “Error_Folder”}/file1.txt | grep -i post-comp | awk ‘{{print $6}’ | sed ‘s/%//’)
VALUE=‘85’
if [[ “$OUTPUT” -lt “$VALUE” ]]; then
echo “Current Utilization “$OUTPUT” is Less than Threshold “$VALUE”,nothing to do” > {parameter “Error_Folder”}/output.txt
cat {parameter “Error_Folder”}/file1.txt >> {parameter “Error_Folder”}/output.txt
echo “0” > {parameter “Error_Folder”}/output1.txt
else
echo “Current Utilization “$OUTPUT” is more than or equal to Threshold “$VALUE”,Follow the Remediation steps” > {parameter “Error_Folder”}/file2.txt
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ filesys clean status > {parameter “Error_Folder”}/file3.txt
grep finished {parameter “Error_Folder”}/file3.txt
echo $? > {parameter “Error_Folder”}/file4.txt
VALUE1=cat {parameter “Error_Folder”}/file4.txt
VALUE2=“0”
if [[ “$VALUE1” -gt “$VALUE2” ]]; then
sleep 180
else
echo “Clean Status Has been Completed,now execute the filesys clean start” > {parameter “Error_Folder”}/file5.txt
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ filesys clean start > {parameter “Error_Folder”}/file6.txt
sleep 240
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ filesys clean watch > {parameter “Error_Folder”}/file7.txt
grep “100.0% complete” {parameter “Error_Folder”}/file7.txt
echo $? > {parameter “Error_Folder”}/file8.txt
VALUE3=cat {parameter “Error_Folder”}/file8.txt
VALUE4= “0”
if [[ “$VALUE3” -gt “$VALUE4” ]]; then
sleep 180
else
echo “Cleaning: phase is Completed” > {parameter “Error_Folder”}/file9.txt
sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > {parameter “Error_Folder”}/file10.txt
OUTPUT1=$(cat {parameter “Error_Folder”}/file10.txt | grep -i post-comp | awk ‘{{print $6}’ | sed ‘s/%//’)
if [[ “$OUTPUT1” -lt “$VALUE” ]]; then
echo “Issue has been Fixed, Current Utilization “$OUTPUT1” is Less than Threshold “$VALUE” ,Nothing to do more on this” > /{parameter “Error_Folder”}/output.txt
cat {parameter “Error_Folder”}/file1.txt {parameter “Error_Folder”}/file2.txt {parameter “Error_Folder”}/file3.txt {parameter “Error_Folder”}/file4.txt {parameter “Error_Folder”}/file5.txt {parameter “Error_Folder”}/file6.txt {parameter “Error_Folder”}/file7.txt {parameter “Error_Folder”}/file8.txt {parameter “Error_Folder”}/file9.txt {parameter “Error_Folder”}/file10.txt >> {parameter “Error_Folder”}/output.txt
rm -rf {parameter “Error_Folder”}/pass.txt
rm -rf {parameter “Error_Folder”}/pass.json
rm -rf {parameter “Error_Folder”}/abc.txt
else
cat {parameter “Error_Folder”}/file1.txt {parameter “Error_Folder”}/file2.txt {parameter “Error_Folder”}/file3.txt {parameter “Error_Folder”}/file4.txt {parameter “Error_Folder”}/file5.txt {parameter “Error_Folder”}/file6.txt {parameter “Error_Folder”}/file7.txt {parameter “Error_Folder”}/file8.txt {parameter “Error_Folder”}/file9.txt {parameter “Error_Folder”}/file10.txt > {parameter “Error_Folder”}/error.txt
echo “High Utilization problem cannot be fixed,Current Utilization is “$OUTPUT1” which is more than or equal to Threshold “$VALUE” , Hence transferring the Ticket” >> {parameter “Error_Folder”}/error.txt
echo “1” > {parameter “Error_Folder”}/output1.txt
rm -rf {parameter “Error_Folder”}/pass.txt
rm -rf {parameter “Error_Folder”}/pass.json
rm -rf {parameter “Error_Folder”}/shabir.txt
exit 100
fi
fi
fi
fi
EOF
delete "/tmp/gs/dd.sh"
move __createfile "/tmp/gs/dd.sh"
wait /bin/sh “/tmp/gs/dd.sh”
// Relevance to get Status of this fixlet
if{exists file “output1.txt” whose (exists line whose (it != “0”) of it) of folders (parameter “Error_Folder”)}
exit 100
endif