Relative Content

Tag Archive for bashif-statement

if tests seem to fail even though the variable echo works

I am trying to setup a script that will test for a user and if it doesn’t exist I will add the user to a server. For now I am just testing to see if what I am testing for is found and I can do different actions based on what is returned. When I do echo "$BOBCHECK" after the ssh command I do get either found or missing results back as it runs through my server list so I know that part is working as expected and I have my variable set within the loop cycle. However the only result I get for the if tests is the failed test echo of “exist check failed” like the variable has been reset inside the if statements. Can someone explain what I am doing wrong here?

if tests seem to fail even though the variable echo works

I am trying to setup a script that will test for a user and if it doesn’t exist I will add the user to a server. For now I am just testing to see if what I am testing for is found and I can do different actions based on what is returned. When I do echo "$BOBCHECK" after the ssh command I do get either found or missing results back as it runs through my server list so I know that part is working as expected and I have my variable set within the loop cycle. However the only result I get for the if tests is the failed test echo of “exist check failed” like the variable has been reset inside the if statements. Can someone explain what I am doing wrong here?