SSH script syntax

Viewed 0

Hi

I'm having trouble with finding out how the ssh script is interpreted in combination with the "PA_" actions.

So far I have success in making the following work:

TEST='systemctl status licenseserver.service | grep -q "active (running)"'
 echo "PA_Details($TEST)"

As expected I get "active (running)" in the response.

Now I want to do some more scripting commands. F.ex:

TEST='systemctl status licenseserver.service | grep -q "active (running)"'
LENGTH=${#TEST}
echo "PA_Details($LENGTH)"

This however returns:

Details variable holds:
root@lvps83-169-42-89:~# exit
logout

Why don't I get the length of the string?

I have also experimenting with:

#!/bin/bash
TEST='test string'
 echo "PA_Details($TEST)"

This also gives me:

Details variable holds:
root@lvps83-169-42-89:~# exit
logout

I really can't figure out what is going on.

Best, Rune

1 Answers

I didn't solve all but enough.

The script I got working looks like this:

#!/bin/bash
TEST=$(systemctl status licenseserver.service | grep "active (running)")
LENGTH=${#TEST}
NOTRUNNING=false
if (($LENGTH>0)) ; then
   NOTRUNNING=false
else
   NOTRUNNING=true
fi
echo "PA_FireActions($NOTRUNNING)"

Also bash variables in PA_Details should be enclosed in quotes:

 echo "PA_Details(\"$TEST\")"
Related