Linux/Unix Shell Scripting - Error de Sintaxis Scrip Linux

 
Vista:

Error de Sintaxis Scrip Linux

Publicado por Trebor (2 intervenciones) el 06/05/2013 14:35:03
Hola a tod@s.
Mi problema, es que tengo un script el cual me da un error en la línea que a continuación se encuentra subrayada.
Si veis algo mal, decírmelo, ya que este urge arreglarlo, y no soy gran conocedor de este script.
Antes de nada dar la gracias de antemano.
Aquí el script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
random ()
	{
	#Sets the length of the password the script will generate
	MAXSIZE=12
	password=""
	# Holds valid password characters. I choose alpha-numeric + the shift-number keyboard keys
	array1{
	w e r t y u p a s d f h j k z x c v b m Q W E R T Y U P A D
	F H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 @ % _
	}
	# Used in conjunction with modulus to keep random numbers in range of the array size
	MODNUM=${#array1[*]}
 
	# Keeps track of the number characters in the password we have generated
	pwd_len=0
 
        while [ $pwd_len -lt $MAXSIZE ]
	do
	  index=$(($RANDOM%$MODNUM))
	  password="${password}${array1[$index]}"
	  ((pwd_len++))
	done
#	echo $password
	return 0
	}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 104
Oro
Ha mantenido su posición en Linux/Unix Shell Scripting (en relación al último mes)
Gráfica de Linux/Unix Shell Scripting

bucle while incrementando una variable

Publicado por xve (309 intervenciones) el 06/05/2013 22:45:54
Hola Trebor, no se como lo estas ejecutando, pero esto en bash funciona perfectamente:

1
2
3
4
5
6
7
8
9
10
#!/bin/bash
 
pwd_len=0
MAXSIZE=12
 
while [ $pwd_len -lt $MAXSIZE ]
do
    echo $pwd_len
    let pwd_len=$pwd_len+1
done

para ejecutarlo:
# bash script


Este código es para shell...

1
2
3
4
5
6
7
8
9
10
#!/bin/sh
 
pwd_len=0
MAXSIZE=12
 
while [ $pwd_len -lt $MAXSIZE ]
do
    echo $pwd_len
    pwd_len=$((pwd_len+1))
done

para ejecutarlo:
# sh script

Espero que te sirva... coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

bucle while incrementando una variable

Publicado por Trebor (2 intervenciones) el 07/05/2013 17:29:09
Gracias xve.
Al final utilice otro bash, pero lo e probado y era eso.

Error de novato.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 104
Oro
Ha mantenido su posición en Linux/Unix Shell Scripting (en relación al último mes)
Gráfica de Linux/Unix Shell Scripting

bucle while incrementando una variable

Publicado por xve (309 intervenciones) el 07/05/2013 20:29:23
Hola Trebor, gracias por comentarlo...

Nos puedes mostrar cual has utilizado?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar