lundi 26 juin 2017

If statement in shell script gives ' unmatched even without any ' or "

I have a shell script that worked until I added an if statement.

What I am trying to attempt is if [hostname = "thecorrecthostname"] then some code. Hostname is not a variable I would use $ on... I just can type hostname and it prints. Hostname doesn't seem to be the issue though.

If I wrap it in a if [something = something], no matter whats inside of the check I get syntax error at line 11 : `<<' unmatched. Originally just to check I tried if ["bob" = "bob"] it gives the error, if I put if [5 = 5], I still get the error. Taking out the if statement and keeping my original code works with no errors.

Nowhere in this if statement is there a quote mark so I'm not sure what is triggering the error.

I cannot post this code due to NDA but I can if needed make a pseudo code

This shouldn't be needed since the code is perfect until I attempt an If Statement

Aucun commentaire:

Enregistrer un commentaire