Forum     

Go Back   Digit Technology Discussion Forum > Software > Open Source
Register FAQ Calendar Mark Forums Read

Open Source A place where you can talk to like-minded people about the fastest growing software movement today! Discuss anything and everything about Open Source software and Operating Systems.


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 19-07-2008, 07:54 PM   #1 (permalink)
Tech Addict
 
Join Date: Feb 2004
Location: Kolkata
Posts: 148
Default Script for scheduling Dataone connection in Opensuse


Hi,
I'm using OpenSuse 11.0.
I've a Dataone broadband connection in bridged mode. I use Kinternet to manually connect to internet. I've a limited bandwith net connection which provides unlimited downloads between 2.00-8.00AM.
I've tried to keep running my net connection and scheduling downloads in Ktorrent. But when kept idle, the connecion disconnects after sometime. I've entered Idle Time Out as 0 in DSL settings.

Executing sudo -i and /sbin/ifup dsl0 from terminal starts the net.

I've tried making a script as follows and running it using Kcron

#!/bin/bash
sudo -i
/sbin/ifup dsl0
exit 0

I've removed password for sudo by using Yast also made the file executible from the properties.
But this doesn't work.

Now pls tell me why?


______________
Arup
arupch is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 20-07-2008, 12:01 AM   #2 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: Script for scheduling Dataone connection in Opensuse

"sudo -i" is irrelevant. The logic lies in adding to cron a timing from 2-8, that executes the script every minute or 5 minutes whicheva u like. I had made a script for similar purpose. Here's the modified one for ur use.

Quote:
#!/bin/bash

cd /home/scripts/
ping 208.67.222.222
-c 1 > /dev/null
val=`echo $?`

if [ $val -ne 0 ];then

echo "--> Restarting" >> autostart.log
date >> autostart.log
echo "******************" >> autostart.log

#Command that starts the connection, you can edit this
/sbin/ifup dsl0

fi
1. Save n Name the script say, "nightrider.sh" to a folder say, "/home/scripts" where all ur other scripts are stored.
2. command "chmod +x nightrider.sh" for making it executable
3. For cron u do
Quote:
*/5 2-8 * * * /home/scripts/nightrider.sh
The IP 208.67.222.222 belongs to opendns. It is only there for checking the internet connection status. "autostart.log" is the log generated that shows "when" the script was executed. I hope it works!
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Old 20-07-2008, 09:52 AM   #3 (permalink)
Tech Addict
 
Join Date: Feb 2004
Location: Kolkata
Posts: 148
Default Re: Script for scheduling Dataone connection in Opensuse

Quote:
Originally Posted by arupch View Post
Hi,
#!/bin/bash
sudo -i
/sbin/ifup dsl0
exit 0
Thank you for your reply.
I'll try that.
But above when saved as a file (dsl.sh) and made executible does not starts net when run from terminal.
whyyy??
___________
Arup
arupch is offline  
Old 20-07-2008, 01:18 PM   #4 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: Script for scheduling Dataone connection in Opensuse

U must understand then how the shell scripts work. When u put sudo or su, u r simply "entering" a "new shell" which doesn't know about next lines/commands in the script. So it doesn't matter if u have a password for root or not. It is wrong to put "sudo" in a shell script!

U can remove the sudo part i.e "sudo -i" and initiate the script u created as "sudo sh dsl.sh". U can also remove the "exit 0" part as well..
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Old 20-07-2008, 07:12 PM   #5 (permalink)
Tech Addict
 
Join Date: Feb 2004
Location: Kolkata
Posts: 148
Default Re: Script for scheduling Dataone connection in Opensuse

Thank you for your help. I'm trying to get this issue solved for several days in different forums - but nobody except you helped.

I tried your script: i saved the file as test.sh in desktop - also changed the path statement in the script.

Then executed ./test.sh

Which gave me:
/sbin/ifup: line 207: /dev/shm/sysconfig/config-dsl0: Permission denied
dsl0
error: can't create pid file, Permission denied
error: can't create pid file
failed to bring interface dsl0 up
awk: cmd. line:1: fatal: cannot open file `/etc/ntp.conf' for reading (Permission denied)
awk: cmd. line:1: fatal: cannot open file `/etc/ntp.conf' for reading (Permission denied)
Checking for network time protocol daemon (NTPD): unused
arup@linux-9c3u:~/Desktop> touch: cannot touch `/dev/shm/sysconfig/ready-dsl0': Permission denied

But when I give sudo sh test.sh it works:

dsl0
interface dsl0 is up
Checking for network time protocol daemon (NTPD): unused

So how do I put the Cronjob?
arupch is offline  
Old 20-07-2008, 11:00 PM   #6 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: Script for scheduling Dataone connection in Opensuse

sudo crontab -e. I hope u know how to use the "vi editor"! Its really simple.

Quote:
Originally Posted by arupch
Thank you for your help. I'm trying to get this issue solved for several days in different forums - but nobody except you helped.
You're Welcome.
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Old 21-07-2008, 08:47 AM   #7 (permalink)
TheSaint
 
NucleusKore's Avatar
 
Join Date: Jun 2004
Location: Antigua
Posts: 3,447
Default Re: Script for scheduling Dataone connection in Opensuse

Arupch, it would be nice if you could write a final post detailing the complete instructions and your experience it would be useful for other users, and maybe post the script too.
__________________
http://www.neville.in
http://www.linuxrocks.in
"The Future Is Open"
NucleusKore is offline  
Old 21-07-2008, 09:01 AM   #8 (permalink)
left this forum longback
 
praka123's Avatar
 
Join Date: Sep 2005
Location: -
Posts: 7,536
Default Re: Script for scheduling Dataone connection in Opensuse

@arupch: ifup and all need root permission. why not run the script as root(risky may be!) ,as cron can only execute those commands as su -.
__________________
left this forum long back.Admin Can Delete this Account and posts Permanantly.Thank You
Get GNU/Linux - http://getgnulinux.org
praka123 is offline  
Old 21-07-2008, 10:05 AM   #9 (permalink)
Tech Addict
 
Join Date: Feb 2004
Location: Kolkata
Posts: 148
Default Re: Script for scheduling Dataone connection in Opensuse

Well. Thanks Mediator once again.
I've set the Cronjob as guided by you.
I'll write the detailed steps followed by me soon.

.................

Here are the steps that I followed.
All the credits goes to Mediator - I just followed his instructions.

Quote:
The logic lies in adding to cron a timing from 2-8, that executes the script every minute or 5 minutes whicheva u like. I had made a script for similar purpose. Here's the modified one for ur use.

#!/bin/bash

cd /home/scripts/
ping 208.67.222.222 -c 1 > /dev/null
val=`echo $?`

if [ $val -ne 0 ];then

echo "--> Restarting" >> autostart.log
date >> autostart.log
echo "******************" >> autostart.log

#Command that starts the connection, you can edit this
/sbin/ifup dsl0

fi

1. Save n Name the script say, "nightrider.sh" to a folder say, "/home/scripts" where all ur other scripts are stored.
2. command "chmod +x nightrider.sh" for making it executable
3. sudo crontab -e.
4. For cron u do */5 2-8 * * * /home/scripts/nightrider.sh
The IP 208.67.222.222 belongs to opendns. It is only there for checking the internet connection status. "autostart.log" is the log generated that shows "when" the script was executed.
____________
Arup

Last edited by arupch; 22-07-2008 at 08:40 AM. Reason: Automerged Doublepost
arupch is offline  
Old 24-07-2008, 08:40 PM   #10 (permalink)
TheSaint
 
NucleusKore's Avatar
 
Join Date: Jun 2004
Location: Antigua
Posts: 3,447
Default Re: Script for scheduling Dataone connection in Opensuse

Good work
__________________
http://www.neville.in
http://www.linuxrocks.in
"The Future Is Open"
NucleusKore is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How-to configure a PPPoE Broadband Internet Connection in OpenSuSE 11.0 NucleusKore Tutorials 34 24-07-2009 06:29 AM
How To Setup BSNL Dataone in OpenSuse 11.0? Rahim Open Source 2 19-09-2008 12:12 PM
OpenSuSE 10.3 for standalone PCs without an internet connection NucleusKore Open Source 22 01-01-2008 10:54 PM
scheduling a connection liquid_snake Tutorials 3 26-07-2007 11:01 PM
Dataone usage & PC scheduling webgenius Broadband and DTH 2 08-03-2007 05:57 PM

 
Latest Threads
- by gforz
- by soumya
- by Sujeet
- by icebags
- by Charan

Advertisement




All times are GMT +5.5. The time now is 02:44 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2