LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-22-2005, 08:01 PM   #1
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Change proc value as a user in a script?


Been experimenting and writing more simply scripts and have run into issues that only root can do. I have worked some issues out with sudo but don't think sudo will work for this script.

Need a little help in a simply script I have created. I would like to change the processor speed step but cannot do it as a user. Only root can make the change. What can I do in my script to make it work for a user (really I am the only to make use of it).

Script called Throttle50
Code:
#!/bin/sh

# throttle to 50%
echo -n 4 > /proc/acpi/processor/CPU0/throttling

# copy cpu0 info
cat /proc/acpi/processor/CPU0/info > /storage1/systeminfo/p2

# copy cpu0 throttle speed
cat /proc/acpi/processor/CPU0/throttling > /storage1/systeminfo/p4

# Merge all info into one file
cat /storage1/systeminfo/p* > /storage1/systeminfo/Processorinfo.txt

# Print the output to the screen so as to know script finished correctly
xmessage -center -file /storage1/systeminfo/Processorinfo.txt
Also would like to create simply scripts to stop eth1, change eth1 information (have 6 different wireless sites I visit during a month's time), then restart. I have writing the script to stop and start as user with sudo, but cannot figure out how to rewrite the file:/etc/sysconfig/network-scripts/ifcfg-eth1 as a user but I guess it still needs to remain as root ownership when done. Pretty much the same thing as above


Thanks for your help an time.
Brian1
" Google the Linux way @ http://www.google.com/linux "

Last edited by Brian1; 01-22-2005 at 08:16 PM.
 
Old 01-23-2005, 06:59 AM   #2
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Are you saying that you cannot do this?
sudo echo -n 4 > /proc/acpi/processor/CPU0/throttling

Quote:
but cannot figure out how to rewrite the file:/etc/sysconfig/network-scripts/ifcfg-eth1
If you have 6 files e.g.
wireless1.ifcfg-eth1
wireless2.ifcfg-eth1
wireless3.ifcfg-eth1
wireless4.ifcfg-eth1
wireless5.ifcfg-eth1
wireless6.ifcfg-eth1

Then would this not work?
sudo mv wireless1.ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1
 
Old 01-23-2005, 10:48 AM   #3
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Original Poster
Rep: Reputation: 65
No that does not work for me. It says-
Code:
[crusher58@lcomp58 ~]$ sudo echo -n 4 > /proc/acpi/processor/CPU0/throttling
bash: /proc/acpi/processor/CPU0/throttling: Permission denied
[crusher58@lcomp58 ~]$
I have added /bin/echo to my sudoers file and all other commands work fine from it.

. Haven't tried the networking deal let. I figured if I get this to work then the other would be no problem.

Brian1
" Google the Linux way @ http://www.google.com/linux "
 
Old 01-26-2005, 07:57 PM   #4
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Original Poster
Rep: Reputation: 65
Final figured it out myself. Required using chown first. Here's my script.
Code:
#!/bin/sh

# throttle to 50%
sudo chown brian.brian /proc/acpi/processor/CPU0
sudo chown brian.brian /proc/acpi/processor/CPU0/throttling
sudo echo -n 4 > /proc/acpi/processor/CPU0/throttling
sudo chown root.root /proc/acpi/processor/CPU0/throttling
sudo chown root.root /proc/acpi/processor/CPU0

# copy cpu0 info
cat /proc/acpi/processor/CPU0/info > /storage1/systeminfo/p2

# copy cpu0 throttle speed
cat /proc/acpi/processor/CPU0/throttling > /storage1/systeminfo/p4

# Merge all info into one file
cat /storage1/systeminfo/p* > /storage1/systeminfo/Processorinfo.txt

# Print the output to the screen
xmessage -center -file /storage1/systeminfo/Processorinfo.txt
Thanks all for the help.
Brian1
" Google the Linux way @ http://www.google.com/linux "
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change user in bash script c0d3 Programming 6 07-27-2005 11:34 AM
what is the command to make a user change their password after creating a new user? naweenio Linux - Newbie 7 01-05-2005 07:07 AM
change user pwd in script? slug420 Linux - General 2 10-12-2004 10:26 AM
How to change to root user within a script? bjdea1 Linux - Software 1 09-07-2004 09:58 AM
Change RTC with PROC? Mor_Petrus Programming 1 04-15-2003 12:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:56 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