Action script not working

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

Try modifying the end of your action as

move __createfile "/tmp/gs/dd.sh"
wait chmod +x /tmp/gs/dd.sh
wait /bin/sh -c "/tmp/gs/dd.sh"

Thanks for the reply.

Still there is issue.

if you see my action script, sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > {parameter “Error_Folder”}/file1.txt

In File1.txt output is not coming but same output is coming when i execute it manually.

It looks like you are missing the

createfile until EOF

Hi,

Sorry my mistake, we are using it but here i think i forgot to paste it but we are using it in actual script.

Sorry, but it is very difficult to help on a post like this.

You paste a very long script, and say that dd.sh does not get executed.

We have since learned that there is more to the script (you forgot to paste some lines) and that the real problem is that the content of file1.txt is not what you expect - but without explaining what is different, where the content you expect to see should come from nd what you actually get instead.

Let me shorten this. I have two BigFix environment A and B. It is working fine in A environment but same is not working in B environment. We have found that variable $PASS is not passing the password value, Even if we enter the password manually in place of that variable it is sending Blank instead of password. We can also see the password value inside pass.txt. If i execute the dd.sh manually on machine, then it works fine.

delete __createfile
createfile until EOF

#!/bin/sh
PASS=$(cat {parameter “Error_Folder”}/pass.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/%//’)

EOF

delete "/tmp/gs/dd.sh"
move __createfile "/tmp/gs/dd.sh"
wait chmod +x /tmp/gs/dd.sh
wait /bin/sh -c “/tmp/gs/dd.sh”

Parameter “Error_Folder” doesn’t seem to be defined in the ActionScript?

And I’m not in front of a Linux machine to test, but aren’t back quotes needed to store the output of the command into a variable?

PASS=$(cat {parameter “Error_Folder”}/pass.txt)

“Error_Folder” is the parameter in our case where executor enters the random path. Currently we are giving path as /tmp/gs/

But here the question is if we enter a password Like Goole@123 in place of $PASS then still it does not work.

As a test, try echoing the script commands to a file (NOTE - this will include the test password! )

delete __createfile
createfile until EOF

#!/bin/sh
PASS=$(cat {parameter “Error_Folder”}/pass.txt)
echo sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > {parameter “Error_Folder”}/commandline.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/%//’)

EOF

delete "/tmp/gs/dd.sh"
move __createfile "/tmp/gs/dd.sh"
wait chmod +x /tmp/gs/dd.sh
wait /bin/sh -c “/tmp/gs/dd.sh”

It is getting failed on echo

Completed #!/bin/sh
Completed PASS=$(cat {parameter “Error_Folder”}/pass.txt)
Failed echo sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter
“user_name”}@{parameter “data_domain_server”}’ df -h > {parameter
“Error_Folder”}/commandline.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/%//’)

EOF

delete “/tmp/gs/dd.sh”

move __createfile “/tmp/gs/dd.sh”

wait chmod +x /tmp/gs/dd.sh

wait /bin/sh -c “/tmp/gs/dd.sh”

Above output is taken from action info

Yeah, sorry, you still need to define the Error_Folder parameter, however you were doing it earlier

I tried it too

Completed #!/bin/sh
Completed PASS=$(cat /tmp/gs/pass.txt)
Failed echo sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > /tmp/gs/commandline.txt

sshpass -p $PASS ssh -o StrictHostKeyChecking=no ‘{parameter “user_name”}@{parameter “data_domain_server”}’ df -h > /tmp/gs/file1.txt

OUTPUT=$(cat /tmp/gs/file1.txt | grep -i post-comp | awk ‘{{print $6}’ | sed ‘s/%//’)

EOF

delete “/tmp/gs/dd.sh”

move __createfile “/tmp/gs/dd.sh”

wait chmod +x /tmp/gs/dd.sh

wait /bin/sh -c “/tmp/gs/dd.sh”

If i execute the dd.sh manually on from /tmp/gs directory, it get executed and working fine.

[root@cnsgibmslpz106 gs]# sh -x ./dd.sh
++ cat /tmp/gs/pass.txt

  • PASS=Google123
  • sshpass -p Google123 ssh -o StrictHostKeyChecking=no SA_IATE@abc.net.bcd.com df -h
    EMC Data Domain Virtual Edition
    ++ awk ‘{print $6}’
    ++ cat /tmp/gs/file1.txt
    ++ grep -i post-comp
    ++ sed s/%//

At that point, it’s not even trying to execute the script - it’s still writing the script file. The Relevance substitutions are failing, probably because one of the parameters you’re trying to reference hasn’t been defined in the ActionScript yet.

But not sure how the same action script is working fine in A environment where I am using same action script through different BigFix server and over the different client machine.

Is not the Client or BigFix server issue of the B environment?

Not likely, if it worked in one environment it’s probably an environment problem. Like you’re missing a binary you depend on, or expect something in the system $PATH, or something like that.

I’m not likely going to be able to continue down this path of guessing what you might possibly be doing wrong in a script you still haven’t shown us.