LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2004, 07:02 PM   #1
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
how to run script on event ppp0 interface going down ?


Hello Fellow Penguin Huggers

i have a sucky dial-up ISP that hangs up every 2 hours of connection time.
and i want to leave my pc overnight to download large files.

is there anyway i could detect that the internet has gone down,
and run this sequence of commands....
Quote:
killall wget
/sbin/ifup ppp0
wget -ci DownloadURLS.list
thankyou.
 
Old 02-23-2004, 08:57 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

I think I've got it.

Start this script. You'll have to run it as root to get access to ifconfig. Adjust the sleep number to suit (it's 5 seconds at the moment - that's probably a bit short, YMMV)

Here's the script:

Code:
#!/bin/bash
while true ; do
    ifconfig | grep ppp0 &> /dev/null
    if [ $? != 0 ] ; then
	killall wget
	/sbin/ifup ppp0
	wget -ci DownloadURLS.list &
    fi
sleep 5
done
The script will run for ever, unless stopped by you.

Hope that helps.

Dave

Edit: Added & to end of wget -ci line

Last edited by ilikejam; 02-23-2004 at 09:06 PM.
 
Old 02-23-2004, 09:07 PM   #3
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
ah yes, that works great thanks !!

i though about somthing similar but decided it would eat all my cpu...
didnt realise BASH had a sleep function lol....

thanX for the script.
 
Old 02-23-2004, 09:08 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Did you get the last edit? The ampersand's important.

Dave
 
Old 02-24-2004, 06:08 AM   #5
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
yep thats in there...
(also had to change ifconfig to /sbin/ifconfig if any1 else is reading this)

thanKs
 
  


Reply



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
is it possible to get interface up/down event notifications thru netlink in linux pccyang Programming 1 11-19-2004 07:21 PM
ppp0 interface setup zsjoska Linux - Networking 1 11-04-2004 01:01 PM
interface PPP0 walker#1 Linux - Hardware 4 08-28-2004 07:39 AM
No interface ppp0 exists Likosin Linux - Networking 3 08-09-2004 02:49 AM
how can a program get network interface up/down event notifications in Linux manaskb Programming 1 10-22-2002 04:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:11 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration