Fawzinov
Fawzinov

Reputation: 589

Passing string variable to shell script

I have a shell script contains this condition

 if [ -z "${PEER_ADDRESS}" ]; then
    ##some code here
fi

I'm not able to pass PEER_ADDRESS variable when I run the script.

I tried the below but it always executed the if code

./script.sh PEER_ADDRESS="someString" 
./script.sh $1 ="someString" 
./script.sh "someString"
./script.sh $PEER_ADDRESS="someString" 

Upvotes: 0

Views: 742

Answers (1)

choroba
choroba

Reputation: 242103

The assignment precedes the command:

PEER_ADDRESS="someString" ./script.sh

Upvotes: 3

Related Questions