help with script to bring network up and down please

New to Debian (Or Linux in general)? Ask your questions here!

Re: help with script to bring network up and down please

Postby smallchange » 2010-02-12 13:46

Assuming that you are the installer and administrator of your system there is no reason not to give your user full root privileges with sudo. You seem to not understand the difference between running a script and clicking on it, and that combined with using ifdown as the name of your script when ifdown is an actual system command are causing much confusion.

With a fresh system if you run
Code: Select all
/sbin/ifdown eth0
as root, your network interface should be brought down. To check this you can run
Code: Select all
/sbin/ifconfig
which will list the up interfaces. You can also look at some network monitor icon if that actually works, but using that just adds another chance to fail.

After that create the script that runs /sbin/ifdown eth0, call it something (I prefer something other than ifdown), place it in your PATH, which might include ~/bin if you have added that to your path. Then run the script by running it in a terminal, as root. Then you will know the script works.

Then you can set up an icon/launcher to run your script. You probably should change the script to run either
Code: Select all
sudo /sbin/ifdown eth0
or
Code: Select all
su -c /sbin/ifdown eth0
so the command will be run as root.

You could also use one of the many tools, such as wicd, which provide such functionality.
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: help with script to bring network up and down please

Postby Struggling » 2010-02-12 14:12

mojoman wrote:Like I said above, run it from a terminal. That will help us diagnose the problem (not to mention that GUI is for sissies :wink: )
:D I tried it again from the terminal and it now worked in the root terminal. I'm going to have another look at it tomorrow when I'm fresh and not as cranky with the computer. Thanks for your patience. :)
Novice
Debian Lenny, KDE
Struggling
 
Posts: 143
Joined: 2008-04-20 06:00
Location: Australia

Re: help with script to bring network up and down please

Postby mojoman » 2010-02-12 16:11

smallchange wrote:Assuming that you are the installer and administrator of your system there is no reason not to give your user full root privileges with sudo. You seem to not understand the difference between running a script and clicking on it, and that combined with using ifdown as the name of your script when ifdown is an actual system command are causing much confusion.


Normally I'd agree BUT considering that this would then be full root privileges without password being required AND that the OP doesn't seem that proficient (no offense intended towards OP) I'd probably narrow it down to a few commandos.

Considering my post here this standpoint is of course ludicrous. :lol:
http://www.debianuserforums.org
By the community. For the community.
User avatar
mojoman
 
Posts: 600
Joined: 2006-10-15 18:43

Re: help with script to bring network up and down please

Postby Struggling » 2010-02-12 16:36

Oh, to be honest, I don't care if I run as root, but I know it's not the official "debian way". My internet computer is completely separate from my computers that have stuff on them that I want to keep and it could get nuked without any repercussions at all. Also, I run puppy on my other internet computer (it's also got nothing on it) - for some reason the logitech trackman wheel I've got doesn't work properly in debian on that computer, but it works fine in puppy, and I haven't had the energy to try to find out whether it can be fixed in debian and, if so, how. I need to be in the right frame of mind to tackle computer problems and I get tired/aggravated easily. I'm the first to admit that my knowledge is limited, even though I've been using debian for quite a while now, so I don't take any offence at being called less than proficient. I'm grateful if I get assistance on the forum.
Novice
Debian Lenny, KDE
Struggling
 
Posts: 143
Joined: 2008-04-20 06:00
Location: Australia

Re: help with script to bring network up and down please

Postby smallchange » 2010-02-12 17:02

mojoman wrote:
smallchange wrote:Assuming that you are the installer and administrator of your system there is no reason not to give your user full root privileges with sudo. You seem to not understand the difference between running a script and clicking on it, and that combined with using ifdown as the name of your script when ifdown is an actual system command are causing much confusion.


Normally I'd agree BUT considering that this would then be full root privileges without password being required AND that the OP doesn't seem that proficient (no offense intended towards OP) I'd probably narrow it down to a few commandos.

Considering my post here this standpoint is of course ludicrous. :lol:


The statement "uncommented out the line that makes no password necessary" is ambiguous but I took it to mean "commented out" rather than "uncommented". I considered mentioning that the password should be required but too much info can be counter productive. :)
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: help with script to bring network up and down please

Postby Struggling » 2010-02-13 02:30

smallchange wrote:The statement "uncommented out the line that makes no password necessary" is ambiguous
oops, sorry. I was tired.

What I had previously was a file (or a link to a file) on my desktop. I could press it and the network would go down. That's what I'm trying to do - I can bring the network down by typing in the terminal, or by disabling it in the KDE control centre, but the way I had was quicker/easier. Thanks for your help, I need to sit down and have another crack at figuring out the sudoers file and see if I can get it to work by playing with sudo. I've got some more learning to do.

Thanks again.
Novice
Debian Lenny, KDE
Struggling
 
Posts: 143
Joined: 2008-04-20 06:00
Location: Australia

Re: help with script to bring network up and down please

Postby smallchange » 2010-02-13 02:40

For sudoers, just comment the line that allows access with no password and you will be fine. For getting the script to run when you click on it, that will depend on your Window Manager or Desktop. Are you using KDE? 3.5 or 4? If you want to you could change the permission to suid root and it will run as root. First change the ownership to root as you have, then
Code: Select all
chmod 4755 ifdown
and it will then run as root. Maybe it is already running but doing nothing because it is not running as root.
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: help with script to bring network up and down please

Postby Struggling » 2010-02-13 03:48

smallchange wrote:and it will then run as root. Maybe it is already running but doing nothing because it is not running as root.
Unfortunately, still no joy. I think you may be right about why it isn't working.
Novice
Debian Lenny, KDE
Struggling
 
Posts: 143
Joined: 2008-04-20 06:00
Location: Australia

Re: help with script to bring network up and down please

Postby refracta » 2010-02-13 04:13

no script needed....no muss....no fuss....a simple .desktop file (text file with a .desktop extension) is all you need

using sudo
Code: Select all
[Desktop Entry]
Name=Network Down
Exec=sudo ifconfig eth0 down
Icon=gksu-root-terminal
Terminal=true
Type=Application


not using sudo, have gksu installed
Code: Select all
[Desktop Entry]
Name=Network Down
Exec=gksu ifconfig eth0 down
Icon=gksu-root-terminal
Terminal=true
Type=Application


edit as needed for command and/or root privy granting utility and/or icon preference and/or whatever
refracta
 
Posts: 1235
Joined: 2008-10-26 01:46

Re: help with script to bring network up and down please

Postby Struggling » 2010-02-13 10:28

refracta, I tried your suggestion and it takes the network down, but I can't get it to come back up without a reboot.
Novice
Debian Lenny, KDE
Struggling
 
Posts: 143
Joined: 2008-04-20 06:00
Location: Australia

Previous

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 16 guests

fashionable