LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-25-2009, 04:03 AM   #16
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184

iptables comes to my mind.

Code:
iptables -p tcp --dport 8000 -j REDIRECT --to-port 8001
This would guide every connection coming to port 8000 to port 8001. So you would need to add this line before you start the server on port 8001 and delete it after the server goes down so the other server on port 8000 is reached.
 
Old 09-25-2009, 04:33 AM   #17
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
dear zhjim,
thanks for your fast reply.

whare should i locate the coding?
whr to find iptables...
 
Old 09-25-2009, 05:25 AM   #18
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
iptables is build into every distro i can think off. So no work on your side.


Code:
while [ 1 ]; do
 /usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8000 >> /var/log/htsserver8000.log
***addition start***
iptables -A INPUT -p tcp --dport 8000 -j REDIRECT --to-port 8001
***addition end***
 /usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8001 >> /var/log/htsserver8001.log
***addition start***
iptables -D INPUT -p tcp --dport 8000 -j REDIRECT --to-port 8001
***addition end***
done
This should fairly do the trick. So you can always connect to http://yourhost:8000 regardless where the htsserver actually listens to.


Did you check if the htsserver always falls into background?
 
Old 09-25-2009, 05:39 AM   #19
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
where shoul i locate ths above code? in the init.d
or iptables?
 
Old 09-25-2009, 06:56 AM   #20
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
init.d is the right place
 
Old 09-28-2009, 02:40 AM   #21
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
hi,
I placed the coding in the inittab. Somehow when http://10.17.32.46:8000/server/index.html die,I stl need to key in the url manually to http://10.17.32.46:8001/server/index.html.

Can it be when port 8000 die, it will directly route to port 8001 page and vise cersa.

Is it something to do wth my html coding?

Please advice. thanks
 
Old 09-28-2009, 04:51 AM   #22
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 0
hi,
I placed the coding in the inittab.
Code:
########
while [1];do
wa1:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8000  >> /var/log/htsserver8000.log
***addition start***
wa2:345:respawn:/usr/local/bin/htsserver /usr/local/share/httrack/ path /data/websites lang 1 --port 8001  >> /var/log/htsserver8001.log
***addition start***
iptables -D INPUT -p tcp --dport 8000 -j REDIRECT --to-port 8001
***addition end***
done
Somehow when http://10.17.32.46:8000/server/index.html die,I stl need to key in the url manually to http://10.17.32.46:8001/server/index.html.

Can it be when port 8000 die, it will directly route to port 8001 page and vise cersa.

Is it something to do wth my html coding?

Appreciate ur help and guidiance. thanks in advance :-)
 
Old 09-29-2009, 05:12 AM   #23
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,467
Blog Entries: 11

Rep: Reputation: 184Reputation: 184
Your mixing things up here.
The script I gave you is a script
Inittab is a config file read by init so I doubt that it will actualy evaluate the script.

Take the script an run it on its own. If this leads to the desired behaviour put it into /etc/init.d and have it started on startup or runlevel changes. The link I provided further up will show you how to do it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
since we have no /etc/inittab scrupul0us Ubuntu 19 12-09-2010 05:54 PM
About /etc/inittab zaxonus Linux - General 3 06-04-2007 07:01 AM
rc[0-6] and inittab kpachopoulos Linux - General 1 08-12-2005 05:27 PM
inittab mikedeatworld Linux - Software 3 08-13-2004 11:01 AM
Cant get out of inittab InEeDhElPlInUx Linux - Newbie 3 10-09-2003 03:13 PM


All times are GMT -5. The time now is 09:17 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration