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?
Why is this conditional if statement always evaluating true in bash? [closed]
Closed 16 days ago.
Why is this conditional if statement always evaluating true in bash? [closed]
Closed 16 days ago.
bash/shell – find “non-breaking space” in UTF8 string – only finding when >= 2 nbsp present [closed]
Closed 11 hours ago.
How to compare float numbers in an if conditional in BASH?
My code is:
Bash script reading from CSV seems to ignore variable values
I’m not a Bash expert, but I’ve followed Copilot examples, and the following should work, but it doesn’t: