I have a script (AWS EC2 instance user data) that must create another script:
#!/bin/bash
cat <<EOF > print.sh
#!/bin/bash
CMD="some AWS CLI command with output"
while [ "$CMD" != "in-use"]
do
# wait 2 seconds
done
EOF
I expect the created script to look like that:
#!/bin/bash
while [ "$some command with output" != 'in-use']
do
# wait 2 seconds
done
I need it like this because the command needs to be reevaluated every time the loop loops.
To summarize, i need the while to execute the AWS CLI request every time.
So far did manage to get it to while [ "" != "in-use"]
, while [ "in-use" != "in-use"]
and while [ '' != 'in-use']
(and many similar outputs but not the one i need). Can you shed some light on how this even works, if its possible?
Just to clarify, the command request will return either in-use
or available
but i need it checked every two seconds on subscript execution, not creation.