Join us at IRC!
Understanding is the answer, hatred is the problem, and hackers are the slaves abused and destroyed in the process of peace online - Deshouleres
Wednesday, May 23, 2012
Navigation
Members Online
Total Online: 35
Web Spiders: 15
Guests Online: 32
Members Online: 3

Registered Members: 70162
Newest Member: Windows-2012
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Bash Script

chompish
Member

Posts: 8
Location:
Joined: 01.12.11
Rank:
Wiseman
Posted on 09-12-11 13:58
Not sure if this should be in here, but i couldn't see anywhere else it could go.

I'm trying to write a scblockedript that would set the IP address of the network card. It works, however i'm wondering if there is a more efficient way to code this?

What i've got so far seems like a lot of code for what it is doing.

Code bellow:
#!/bin/bash
STRING="Working"
RECEVIED="1 received"
PINGFILE="./ping.txt"
echo $STRING

#Try DHCP
dhclient

#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt

#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then ./Desktop/Start_Stuff.sh && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 192.168.1.252
ifconfig eth0 up
fi
#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt

#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="192.168.1.252" && ./Desktop/Start_Stuff.sh && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 192.168.0.252
ifconfig eth0 up
fi

#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt

#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="192.168.0.252" && ./Desktop/Start_Stuff.sh && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 10.0.0.252
ifconfig eth0 up
fi

#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt

#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="10.0.0.252" && ./Desktop/Start_Stuff.sh && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 10.0.1.252
ifconfig eth0 up
fi

ping -c 1 www.google.com > /root/Desktop/ping.txt

if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="10.0.1.252" && ./Desktop//Start_Stuff.sh && exit
else echo "shite, its no working" &&

exit


Yes i know i have spelt received wrong :p

Any help would be appreciated
Author

RE: Bash Script

chompish
Member

Posts: 8
Location:
Joined: 01.12.11
Rank:
Wiseman
Posted on 14-12-11 21:38
Have a really posted a topic that no-one is going to give abuse on? :D

Or give any input for that matter :right:
Author

RE: Bash Script

starofale
Member



Posts: 211
Location: England
Joined: 05.12.07
Rank:
God
Posted on 15-12-11 00:30
Use functions and loops to reduce repeated code.


Try a new search engine
Author

RE: Bash Script

Arabian
Member



Posts: 320
Location: inside you.
Joined: 22.09.10
Rank:
God
Posted on 15-12-11 02:43
starofale wrote:
Use functions and loops to reduce repeated code.


^perfect response.


Hare Lambda!

Author

RE: Bash Script

Mb0742
Member



Posts: 189
Location:
Joined: 26.11.07
Rank:
Hacker Level 2
Posted on 15-12-11 09:19
Oh wow bash has functions. Cheers to this thread.

Oh wait I'm retarded, I've used fork bombs and shit. :angry:


Mb

Edited by Mb0742 on 15-12-11 09:20
javascript:alert("hi")
Author

RE: Bash Script

chompish
Member

Posts: 8
Location:
Joined: 01.12.11
Rank:
Wiseman
Posted on 15-12-11 13:25
thanks kindly :)
Author

RE: Bash Script

Death_metal666
Member



Posts: 35
Location:
Joined: 26.05.11
Rank:
God
Warn Level: 50
Posted on 15-12-11 18:57
starofale wrote:
Use functions and loops to reduce repeated code.

:D


Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.