Yeah, it's only been a day, but maybe I didn't explain so well.
Here's another example. Why doesn't the 3rd invocation produce the same results as the first? I need to invoke the 3rd way in my real script because it's nested inside of 2 loops.
echo No vars
blquery CHIASP75.ent.ad.ntrs.com -e 'service_exists ("MSSQLSERVER")'
echo Host var
blquery $HOST -e 'service_exists ("MSSQLSERVER")'
echo Svc var
blquery CHIASP75.ent.ad.ntrs.com -e 'service_exists ("$SVC")'
Started running the job 'please_kill_me'
Exit Code 0
The job 'please_kill_me' has succeeded
As your $SVC is between cote, it isn't substitute. You should write something like :
blquery CHIASP75.ent.ad.ntrs.com -e $QUERY
The usage of blquery is very specific. The service name must be within double quotes, and the expression must be within single quotes.
I've tried many variations, but any deviation from that fails.
My full script has this statement nested with a couple for loops (for $SERVER, for $SVC) so I need to use a service variable. Tried your suggestion, but it still uses quotes which prevent expansion.
blquery whatevermyserveris.com -e 'service_exists ("'$
'")' #thats double quotes single quotes $single quotes double quotes
Gives a return code of 1 if service exists
I've tried this on my laptop and to me it seems OK :
Here we are going to concatenate two strings with a variable in between:
COMMAND="blquery $HOST -e 'service_exists (\""$SERVICE"\")'"
nsh -c "$COMMAND"
So sorry Stephen, your suggestion does work!
I was just spelled the service name wrong when I tested your code (doh)!
Could you explain how that combination of single/double quotes and braces allows the variable to expand?