Nested if statement execution error [duplicate]
up vote
-1
down vote
favorite
This question is an exact duplicate of:
Combine if statements [on hold]
I am trying to write a nested-if statement in shell script. Script is given below.
#select the snapshot or release
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
elif [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
In this script only execute "192.168.94.140" section. How can I correct this?
linux bash shell
marked as duplicate by RalfFriedl, elbarna, muru, Kusalananda, roaima 2 days ago
This question was marked as an exact duplicate of an existing question.
add a comment |
up vote
-1
down vote
favorite
This question is an exact duplicate of:
Combine if statements [on hold]
I am trying to write a nested-if statement in shell script. Script is given below.
#select the snapshot or release
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
elif [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
In this script only execute "192.168.94.140" section. How can I correct this?
linux bash shell
marked as duplicate by RalfFriedl, elbarna, muru, Kusalananda, roaima 2 days ago
This question was marked as an exact duplicate of an existing question.
Tryset -x
to see what happens.
– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question is an exact duplicate of:
Combine if statements [on hold]
I am trying to write a nested-if statement in shell script. Script is given below.
#select the snapshot or release
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
elif [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
In this script only execute "192.168.94.140" section. How can I correct this?
linux bash shell
This question is an exact duplicate of:
Combine if statements [on hold]
I am trying to write a nested-if statement in shell script. Script is given below.
#select the snapshot or release
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
elif [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
In this script only execute "192.168.94.140" section. How can I correct this?
This question is an exact duplicate of:
Combine if statements [on hold]
linux bash shell
linux bash shell
edited 2 days ago
Rui F Ribeiro
38.2k1475125
38.2k1475125
asked 2 days ago
Janith
12
12
marked as duplicate by RalfFriedl, elbarna, muru, Kusalananda, roaima 2 days ago
This question was marked as an exact duplicate of an existing question.
marked as duplicate by RalfFriedl, elbarna, muru, Kusalananda, roaima 2 days ago
This question was marked as an exact duplicate of an existing question.
Tryset -x
to see what happens.
– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago
add a comment |
Tryset -x
to see what happens.
– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago
Try
set -x
to see what happens.– RalfFriedl
2 days ago
Try
set -x
to see what happens.– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
This works for me.
relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL"
snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"
source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz)
selectDevSnap(){
devDestination=(proj@192.168.94.139:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$snapVersion"
scp $source $devDestination
ssh proj@192.168.94.139 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
selectProdRel(){
prodDestination=(proj@192.168.94.140:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$relVersion"
scp $source $prodDestination
ssh proj@192.168.94.140 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
fi
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
Sure, but we still don't know what$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.
– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This works for me.
relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL"
snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"
source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz)
selectDevSnap(){
devDestination=(proj@192.168.94.139:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$snapVersion"
scp $source $devDestination
ssh proj@192.168.94.139 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
selectProdRel(){
prodDestination=(proj@192.168.94.140:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$relVersion"
scp $source $prodDestination
ssh proj@192.168.94.140 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
fi
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
Sure, but we still don't know what$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.
– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
add a comment |
up vote
0
down vote
This works for me.
relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL"
snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"
source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz)
selectDevSnap(){
devDestination=(proj@192.168.94.139:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$snapVersion"
scp $source $devDestination
ssh proj@192.168.94.139 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
selectProdRel(){
prodDestination=(proj@192.168.94.140:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$relVersion"
scp $source $prodDestination
ssh proj@192.168.94.140 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
fi
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
Sure, but we still don't know what$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.
– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
add a comment |
up vote
0
down vote
up vote
0
down vote
This works for me.
relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL"
snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"
source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz)
selectDevSnap(){
devDestination=(proj@192.168.94.139:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$snapVersion"
scp $source $devDestination
ssh proj@192.168.94.139 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
selectProdRel(){
prodDestination=(proj@192.168.94.140:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$relVersion"
scp $source $prodDestination
ssh proj@192.168.94.140 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
fi
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
This works for me.
relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL"
snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"
source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz)
selectDevSnap(){
devDestination=(proj@192.168.94.139:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$snapVersion"
scp $source $devDestination
ssh proj@192.168.94.139 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
selectProdRel(){
prodDestination=(proj@192.168.94.140:/usr/share/nginx/PROJFRONTEND/proj.com/)
wget "$relVersion"
scp $source $prodDestination
ssh proj@192.168.94.140 "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"
}
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
$SELECT_SNAPSHOT_VERSION
echo "Snapshot Selected"
if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ]
then
$SELECT_RELEASE_VERSION
echo "Release Selected"
fi
if [ "$Server_Selection" == "192.168.94.139" ]
then
selectDevSnap;
echo "deployed to 139"
elif [ "$Server_Selection" == "192.168.94.140" ]
then
selectProdRel
echo "deployed to 140"
else
echo "ERROR"
fi
else
echo "Error Selection"
fi
edited 2 days ago
answered 2 days ago
Janith
12
12
Sure, but we still don't know what$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.
– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
add a comment |
Sure, but we still don't know what$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.
– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
Sure, but we still don't know what
$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.– Kusalananda
2 days ago
Sure, but we still don't know what
$SELECT_RELEASE_VERSION
is (it's treated as code here), or what any of the other variables are. It's hard to debug a program when you don't know what it looks like and under what data it takes to reproduce the bug.– Kusalananda
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
Yeah, But I am working on Jenkins Deployment Project. $SELECT_RELEASE_VERSION is the variable I assigned into a plugin
– Janith
2 days ago
add a comment |
Try
set -x
to see what happens.– RalfFriedl
2 days ago
Why did you start another question for unix.stackexchange.com/questions/483119/… ?
– RalfFriedl
2 days ago
What are the values of the involved variables?
– Kusalananda
2 days ago
@RalfFriedl Previously I did'nt have an idea how to combine those two scripts. But I tried and got an answer, in here I got an error in the script.
– Janith
2 days ago