Não sei qual o erro!!

1. Não sei qual o erro!!

Matheus de Andrade Flausino
MatheusFlausino

(usa Ubuntu)

Enviado em 30/10/2016 - 22:03h

Galera quando executo o seguinte comando:
sh start.sh 

o seguinte erro aparece : start.sh: 25: start.sh: Syntax error: "(" unexpected (expecting "fi")

O shell script (start.sh) é o seguinte:
1   #!/bin/tcsh
2
3 set wait = 0
4 set host = "localhost"
5 set team = "CmorQ2009"
6 set prog = "bin/CmorQ_player"
7 set coach = "bin/CmorQ_coach"
8 set pconf = "Configs/player.conf"
9 set fconf = "Configs/formations.conf"
10
11
12 if( $#argv > 0 && ($argv[$#argv] !~ [0123456789]* || $argv[$#argv] =~ *.* ) ) then
13 @ second_last = $#argv - 1
14 if( $#argv > 1 && ($argv[$second_last] !~ [0123456789]* || $argv[$second_last] =~ *.* ) ) then
15 set host = $argv[$second_last]
16 set team = $argv[$#argv]
17 else
18 set host = $argv[$#argv]
19 endif
20 endif
21
22 if( $1 =~ [0123456789]* && $1 !~ *.* ) then
23 echo "$argv[$#argv]"
24 echo "$1"
25 foreach arg ($argv)
26 if( $arg =~ [123456789]* && $arg !~ *.*) then
27 ${prog} -num ${arg} -host ${host} -team ${team} -f ${fconf} -c ${pconf} &
28 sleep $wait
29 else if( $arg =~ [0]* ) then
30 sleep 2
31 ${coach} -host ${host} -team ${team} -f ${fconf} &
32 endif
33 end
34 else
35 set i = 1
36 while ( ${i} <12 )
37 ${prog} -log 101 -number ${i} -host ${host} -team ${team} -f ${fconf} -c ${pconf} &
38 sleep $wait
39 @ i++
40 end
41 sleep 2
42 ${coach} -host ${host} -team ${team} -f ${fconf} &
43 endif




  


2. Re: Não sei qual o erro!!

Paulo Jr
Pebis

(usa Debian)

Enviado em 30/10/2016 - 22:10h

Acho que está faltando um endif


3. Re: Não sei qual o erro!!

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 30/10/2016 - 22:20h

MatheusFlausino escreveu:

Galera quando executo o seguinte comando:
sh start.sh 

o seguinte erro aparece : start.sh: 25: start.sh: Syntax error: "(" unexpected (expecting "fi")

O shell script (start.sh) é o seguinte:
1   #!/bin/tcsh
2
3 set wait = 0
4 set host = "localhost"
5 set team = "CmorQ2009"
6 set prog = "bin/CmorQ_player"
7 set coach = "bin/CmorQ_coach"
8 set pconf = "Configs/player.conf"
9 set fconf = "Configs/formations.conf"
10
11
12 if( $#argv > 0 && ($argv[$#argv] !~ [0123456789]* || $argv[$#argv] =~ *.* ) ) then
13 @ second_last = $#argv - 1
14 if( $#argv > 1 && ($argv[$second_last] !~ [0123456789]* || $argv[$second_last] =~ *.* ) ) then
15 set host = $argv[$second_last]
16 set team = $argv[$#argv]
17 else
18 set host = $argv[$#argv]
19 endif
20 endif
21
22 if( $1 =~ [0123456789]* && $1 !~ *.* ) then
23 echo "$argv[$#argv]"
24 echo "$1"
25 foreach arg ($argv)
26 if( $arg =~ [123456789]* && $arg !~ *.*) then
27 ${prog} -num ${arg} -host ${host} -team ${team} -f ${fconf} -c ${pconf} &
28 sleep $wait
29 else if( $arg =~ [0]* ) then
30 sleep 2
31 ${coach} -host ${host} -team ${team} -f ${fconf} &
32 endif
33 end
34 else
35 set i = 1
36 while ( ${i} <12 )
37 ${prog} -log 101 -number ${i} -host ${host} -team ${team} -f ${fconf} -c ${pconf} &
38 sleep $wait
39 @ i++
40 end
41 sleep 2
42 ${coach} -host ${host} -team ${team} -f ${fconf} &
43 endif



Boa Noite Matheus.
Não conheço a "sintaxe" dos comandos em "tcsh", mas, se for
igual ao "bash", os condicionais "if" estão incorretos, os mesmos são encerrados com "fi"
e após a condição, tem ";"
X=10 ; if ((X>=5));then
echo "MAIOR QUE 5"
else
echo "MENOR QUE 5"
fi

att.:
Marcelo Oliver






4. Re: Não sei qual o erro!!

Matheus de Andrade Flausino
MatheusFlausino

(usa Ubuntu)

Enviado em 30/10/2016 - 22:21h

Bom, pelo que vi nada net essa sintaxe
if
...
else if
...
endif

com apenas um endif é válida, não?


5. Re: Não sei qual o erro!!

Paulo Jr
Pebis

(usa Debian)

Enviado em 30/10/2016 - 22:34h

remova os parênteses da linha 25



  



Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts