d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programmers Haven Is Dead, So I Ask Here Instead?
12Next
Add Reply New Topic New Poll
Member
Posts: 9,718
Joined: Jan 29 2007
Gold: 0.00
Apr 18 2013 10:57am
Working on a unix shell script, and for some reason i can't get my if statements to work. Have no problems with any of hte other scripts we're required to write this ones being a whore.

here is the error i'm getting:
http://puu.sh/2CrLF.png


here is my script

http://puu.sh/2CrMG.png

Why is it telling me i have one to many fi(closes an if statement) ?
If i remove it it complains the script ends unexpectedly, if i add another its an error code as well.
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Apr 18 2013 11:25am
shouldn't the elif on line 24 be an else instead? It also looks like you closed your if too before the else clause there. I hate reading shell scripts.

This post was edited by rockonkenshin on Apr 18 2013 11:26am
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 18 2013 12:01pm
its not dead its just that theres only literally 5 of us that go there who actually know how to program.

anyways youre missing the "then" statement after the elif.

id also detab both the elif and the other line because they belong to the first if statement. it makes it incredibly hard to read if you dont follow normal tab rules.
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Apr 18 2013 12:49pm
Quote (AbDuCt @ Apr 18 2013 01:01pm)
its not dead its just that theres only literally 5 of us that go there who actually know how to program.

anyways youre missing the "then" statement after the elif.

id also detab both the elif and the other line because they belong to the first if statement. it makes it incredibly hard to read if you dont follow normal tab rules.


I never shell script anymore and I can't remember any of the syntax. :(
Member
Posts: 9,718
Joined: Jan 29 2007
Gold: 0.00
Apr 18 2013 02:15pm
it was the "then" after elif. Also i had -eq instead of == for -i and -o so when i fixed the syntax error it kept outputting an error since -i and -o weren't integers.
All runs well now. According to the professor i should be confident walking into this exam. Still not to sure about it :{
Member
Posts: 1,365
Joined: Oct 20 2002
Gold: 0.12
Apr 18 2013 02:32pm
for what its worth (not much) you misspelled arguments on line 9.
Member
Posts: 25,794
Joined: Oct 7 2005
Gold: 9,510.00
Apr 18 2013 04:39pm
Quote (AbDuCt @ Apr 18 2013 10:01am)
its not dead its just that theres only literally 5 of us that go there who actually know how to program.

anyways youre missing the "then" statement after the elif.

id also detab both the elif and the other line because they belong to the first if statement. it makes it incredibly hard to read if you dont follow normal tab rules.


Whoa whoa whoa, you don't know every language automatically bro.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 18 2013 04:47pm
Quote (Halfdead14 @ Apr 18 2013 06:39pm)
Whoa whoa whoa, you don't know every language automatically bro.


what?
Member
Posts: 105,144
Joined: Apr 25 2006
Gold: 10,475.00
Apr 18 2013 04:49pm
Quote (Halfdead14 @ Apr 18 2013 06:39pm)
Whoa whoa whoa, you don't know every language automatically bro.



When you can code is Assembly...ya sorta do :)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 18 2013 04:52pm
Quote (Ghot @ Apr 18 2013 06:49pm)
When you can code is Assembly...ya sorta do  :)


not really.

once you obtained enough programming logic you can see flaws and it's a quick google search most of the time to find syntax errors. i noticed that elif looked wrong so i googled elif bash and lo and behold it was missing the "then" keyword.

i hardly touch bash scripting. i mostly just write one liners to reset my nic or tor and stuff before i reset my router.
Go Back To Computers & IT Topic List
12Next
Add Reply New Topic New Poll