Indonesian Back|Track Team
[help] kok error else dalam bash script - Printable Version

+- Indonesian Back|Track Team (https://www.indonesianbacktrack.or.id/forum)
+-- Forum: General Zone (https://www.indonesianbacktrack.or.id/forum/forum-172.html)
+--- Forum: Programming (https://www.indonesianbacktrack.or.id/forum/forum-95.html)
+---- Forum: Bash (sh) (https://www.indonesianbacktrack.or.id/forum/forum-96.html)
+---- Thread: [help] kok error else dalam bash script (/thread-2374.html)



[help] kok error else dalam bash script - Junior Riau - 05-06-2012

misi teman",, ini saya coba kembangin tools live ip cheker yang semalam di post di sini

maksudnya ingin nambahin pilihan untuk melakukan scanning atau tidak ,,
berikut kode nya

Code:
#!/bin/bash
#!/original by predi
#!/editing by junior.riau18

echo '
__    __                                           __                 __
|  |  |  | ________  ________    __      _______   |  |      ________ |  |
|  |__|  ||        ||   _____| _|  |__  |   ____|  |  |____ |    _   ||  | __
|        ||   __   ||  |_____ |_    __| |  |       |   _   ||   |_|  ||  |/  /
|   __   ||  |__|  ||_____   |  |  |    |  |     _ |  | |  ||   _____||     /
|  |  |  ||        | _____|  |  |  |_   |  |____| ||  | |  ||  |_____ |     \
|__|  |__||________||________|  |____|  |_________||__| |__||________||__|\__\
'

#!input net id
echo -n -e "Input your Net ID target(such as 192.168.0.): ";
read ip
echo -n -e "Would you want to save the target and continue with host fingerprinting?(y)/(n): ";
read fp

if ["$fp"=="n"]
for i in {1..10}
do
{
iptest=$ip$i
ping -c 1 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
}
done

else
declare -a targetip
a=0;
for i in {1..10}
do
{
iptest=$ip$i
ping -c 2 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
targetip["$a"]=$iptest;
let a=$a+1;
}
done
echo "Launch nmap -O"
nmap -O ${targetip[0]};
fi
exit;

setelah dijalankan terdapat error sebagai berikut

Code:
root@bt:~/cekiplive# ./ceklive.sh

__    __                                           __                 __
|  |  |  | ________  ________    __      _______   |  |      ________ |  |
|  |__|  ||        ||   _____| _|  |__  |   ____|  |  |____ |    _   ||  | __
|        ||   __   ||  |_____ |_    __| |  |       |   _   ||   |_|  ||  |/  /
|   __   ||  |__|  ||_____   |  |  |    |  |     _ |  | |  ||   _____||     /
|  |  |  ||        | _____|  |  |  |_   |  |____| ||  | |  ||  |_____ |     \
|__|  |__||________||________|  |____|  |_________||__| |__||________||__|\__\

Input your Net ID target(such as 192.168.0.): 10.75.42.
Would you want to save the target and continue with host fingerprinting?(y)/(n): n
./ceklive.sh: line 31: syntax error near unexpected token `else'
./ceklive.sh: line 31: `else'
root@bt:~/cekiplive#

mohon koreksi script nya,, maklum hampir 3 tahun g nyentuh bash lagi

error nya di else,,perasaan g salah ketik,,
makasih

regards junior


RE: [help] kok error else dalam bash script - Udalah - 06-13-2012

ane coba bantu ni om, sorry klu salah ya, baru megang bactrack 2 bulan, n ane baru liat bash script ini yg prtama

jadi kn scriptnya gini

(05-06-2012, 11:19 AM)junior.riau18 Wrote: if ["$fp"=="n"]
for i in {1..10}
do
{
iptest=$ip$i
ping -c 1 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
}
done

trus ane rubah jadi gini
Code:
if ["$fp"=="n"];
then
for i in {1..10}
do
{
iptest=$ip$i
ping -c 1 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
}
done

jadi, setelah statement if, itu musti ditutup make ";" biar ga tembus, terus di tambahin then

ni ssnya

[Image: 6y1w6x.png]

tapi skrng muncul error gini

./ipchecker.sh: line 21: [y==n]: command not found

ane ga tau lagi gmn, smoga membantu Smile





RE: [help] kok error else dalam bash script - revzter - 06-13-2012

biar yg dibawah yg bantu yah pusing ane Angry


RE: [help] kok error else dalam bash script - Junior Riau - 06-13-2012

(06-13-2012, 01:35 AM)Udalah Wrote: ane coba bantu ni om, sorry klu salah ya, baru megang bactrack 2 bulan, n ane baru liat bash script ini yg prtama

jadi kn scriptnya gini

(05-06-2012, 11:19 AM)junior.riau18 Wrote: if ["$fp"=="n"]
for i in {1..10}
do
{
iptest=$ip$i
ping -c 1 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
}
done

trus ane rubah jadi gini
Code:
if ["$fp"=="n"];
then
for i in {1..10}
do
{
iptest=$ip$i
ping -c 1 $iptest > /dev/null
[ $? -eq 0 ] && echo Host with IP: $iptest is live.
}
done

jadi, setelah statement if, itu musti ditutup make ";" biar ga tembus, terus di tambahin then

ni ssnya

[Image: 6y1w6x.png]

tapi skrng muncul error gini

./ipchecker.sh: line 21: [y==n]: command not found

ane ga tau lagi gmn, smoga membantu Smile

thanks udah bantu yak
nanti ane revisi lagi tools nya ^_^