0

Hi everybody,

I'm sorry If I ask a silly question. I have a simple code like this

#!/bin/bash

verify()
{

    // do something
    return $(grep -q 'VERIFICATION SUCCESSFUL' result.txt)

}

if [ verify 'a Condition' ]; then

    echo debug

fi

I have the following error:

line x: [: verify: unary operator expected

Can anyone explain for me why I have this error, and how can I correct it?
Thanks in advance.

Edited by Dark2Bright: n/a

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by JeoSaurus
0

Hello Dark2Bright!

I'm not sure what you're trying to do with 'verify' in this case, but the 'verify' command seems to be pretty specific:

verify - Utility to verify certificates.

Are you trying to verify a certificate in this 'if' statement? If not, what condition are you testing?

Thanks!

0

Hi, thanks for your reply.
verify is a function I define for myself (you can see the code above), not a Unix command. I figure out the problem, I made it wrong, I should do like this:

if verify 'a Condition'; then

The script will run correctly.

0

Oh, I see... How did I miss that? Looks like I also missed that the 'verify' that I found was not a command, but an argument to 'openssl'... I'll go back to my corner now...

Thanks for the follow-up :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.