0

I try to run this script against a remote machine, to carry out login check, but have some problems executing it with no errors. I have the following error when I run the script: The Error:

bash: -c: option requires an argument
bash: line 2: [: missing `]'

The Shell Script:

#!/bin/bash
ssh [email protected] bash -c '
radtest user password 127.0.0.1 100 testing | grep 'Access-Accept' &> /dev/null
if [ $? == 0]; then
        echo "match"
fi
'

Any ideas what could cases the error? Note: ssh doesn't need a password here.

Gazel
  • 33
  • 1
  • 9
  • You can compress that to: `if radtest user password 127.0.0.1 100 testing | grep -q "Access-Accept"; then ...` – muru Feb 17 '15 at 23:17

1 Answers1

1

I think this:

if [ $? == 0];

should be:

if [ $? == 0 ];

But as muru suggested it can be:

#!/bin/bash
ssh [email protected] bash -c '"
if radtest user password 127.0.0.1 100 testing | grep -q "Access-Accept"; then
echo "Match"
fi
"'
taliezin
  • 9,085
  • 1
  • 34
  • 38