| View previous topic :: View next topic |
| Author |
Message |
gothbox n00b


Joined: 15 Mar 2005 Posts: 11 Location: Norway
|
Posted: Tue Mar 02, 2010 9:29 pm Post subject: a simple netcat script |
|
|
i need some help to put toghether a simple script to check if port 80 is open (netcat?)
# nc -z -v localhost 80
localhost [127.0.0.1] 80 (http) open
and if not , to start a script ...
something to set as a cron job maybe ?
im very new to programming , but this shouldnt be to hard ?
thanks alot  _________________ its only wrong if you get caught |
|
| Back to top |
|
 |
Naib Advocate


Joined: 21 May 2004 Posts: 3927 Location: UK - Birmingham
|
Posted: Tue Mar 02, 2010 9:33 pm Post subject: |
|
|
if lsof -i :80 >/dev/null; then echo "port 80 in use"; fi _________________ A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen. |
|
| Back to top |
|
 |
gothbox n00b


Joined: 15 Mar 2005 Posts: 11 Location: Norway
|
Posted: Tue Mar 02, 2010 9:40 pm Post subject: |
|
|
that didnt tell me to much to be honest , what does it do ?
i have a ssh session with tunnels running on my school computer , back home , and i need it to be restarted if either my home pc or school pc goes down..
i have no control from home , and would like the script to be restarted if my home computer goes down f,ex ..
its started each time the school pc boots _________________ its only wrong if you get caught |
|
| Back to top |
|
 |
Naib Advocate


Joined: 21 May 2004 Posts: 3927 Location: UK - Birmingham
|
Posted: Tue Mar 02, 2010 9:45 pm Post subject: |
|
|
it checks if port-80 is open (needs to be run by root since it is a priv port) and if it is prints that str to the screen _________________ A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen. |
|
| Back to top |
|
 |
gothbox n00b


Joined: 15 Mar 2005 Posts: 11 Location: Norway
|
Posted: Tue Mar 02, 2010 9:59 pm Post subject: |
|
|
hahahahahahahaha!
i love you !!!
this is just what i want !
best wishes  _________________ its only wrong if you get caught |
|
| Back to top |
|
 |
Naib Advocate


Joined: 21 May 2004 Posts: 3927 Location: UK - Birmingham
|
Posted: Tue Mar 02, 2010 10:04 pm Post subject: |
|
|
 _________________ A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen. |
|
| Back to top |
|
 |
Ant P. Veteran

Joined: 18 Apr 2009 Posts: 1917 Location: UK
|
Posted: Tue Mar 02, 2010 10:18 pm Post subject: |
|
|
This one's longer but it'll work without root:
| Code: | if netstat -tuna | grep ':80 .*LISTEN' > /dev/null; then
# local port 80 is open
else
# isn't
fi |
|
|
| Back to top |
|
 |
gothbox n00b


Joined: 15 Mar 2005 Posts: 11 Location: Norway
|
Posted: Tue Mar 02, 2010 11:45 pm Post subject: |
|
|
ill have a look at it thanks alot _________________ its only wrong if you get caught |
|
| Back to top |
|
 |
|