Active Topics

 


Reply
Thread Tools
Posts: 30 | Thanked: 4 times | Joined on Dec 2009
#1
I'm a bit of a linux noob so bear with me.

Basically i wonder if theres a way i can store two commands for x terminal and store them in a file which i could just open and it would execute the commands for me, like how .bat files do with command prompt in windows.

This would make my life much easier as i can't find a way to copy and paste in x terminal.

sudo gainroot;
echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/power_level;

This is what i'd like to do, a solution like this would save me lots of tedious typing every car journey
 
Posts: 336 | Thanked: 610 times | Joined on Apr 2008 @ France
#2
Code:
echo "#!/bin/bash" > powerlevel.sh
echo "sudo gainroot; echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/powerlevel;" >> powerlevel.sh
chmod +x powerlevel.sh
 

The Following 2 Users Say Thank You to CrashandDie For This Useful Post:
Posts: 36 | Thanked: 28 times | Joined on Nov 2009 @ Hungary
#3
Pretty good, 2 small things:
-there is no bash in the default install, and i'm not sure if the symlink exists, so please change the first line to "#!/bin/sh"
-you forgot to mention, that the script can be run by issuing the following command from the x terminal:
./powerlevel.sh
 

The Following 2 Users Say Thank You to Z0l For This Useful Post:
Posts: 30 | Thanked: 4 times | Joined on Dec 2009
#4
thanks guys for your quick replies. this looks like what i would need, so just to check, do i type the code as crashanddue posted in x terminal and it will create the file, and then to run i just need to type ./powerlevel.sh as zio said?
 
Posts: 36 | Thanked: 28 times | Joined on Nov 2009 @ Hungary
#5
Yes, you type in this in X Terminal:
Code:
echo "#!/bin/sh" > powerlevel.sh
echo "sudo gainroot; echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/powerlevel;" >> powerlevel.sh
chmod +x powerlevel.sh
after this, you can run it anytime by typing this
Code:
./powerlevel.sh
 

The Following User Says Thank You to Z0l For This Useful Post:
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#6
Code:
#!/bin/sh

echo "echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/power_level" | sudo gainroot
Be sure to chmod +x. The echo into sudo gainroot is important - or, otherwise, it'll try echoing into power_level as user, not as root.

Last edited by qwerty12; 2010-01-03 at 23:06.
 

The Following 3 Users Say Thank You to qwerty12 For This Useful Post:
Posts: 30 | Thanked: 4 times | Joined on Dec 2009
#7
I think i have this problem, i have write the script as written above amd made the change zoi said, it works fine when i run it when i'm already root in xterm however it doesn't change the powerlevel if i run it as user, even though the sudo root command is in there, all it does is give me root access.

Any ideas what i need to change?
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#8
Originally Posted by LozBlake View Post
I think i have this problem, i have write the script as written above amd made the change zoi said, it works fine when i run it when i'm already root in xterm however it doesn't change the powerlevel if i run it as user, even though the sudo root command is in there, all it does is give me root access.

Any ideas what i need to change?
http://talk.maemo.org/showpost.php?p=451774&postcount=6
 
Posts: 247 | Thanked: 37 times | Joined on Aug 2009 @ Los Angeles
#9
is the problem that it should be entered as one line? My browser splits the part after the pipe onto a new line.
 
Posts: 271 | Thanked: 220 times | Joined on Sep 2009
#10
Originally Posted by LozBlake View Post
I think i have this problem, i have write the script as written above amd made the change zoi said, it works fine when i run it when i'm already root in xterm however it doesn't change the powerlevel if i run it as user, even though the sudo root command is in there, all it does is give me root access.

Any ideas what i need to change?
You can't use sudo like that...the "sudo gainroot" launches a new shell process but the next command in your script executes in the exiting "user"-owned shell. It's not a hard problem to fix in a "normal" linux distro (I typically use "su" with flags to switch users inside a script) but I'm not sure how you would do it with the seemingly unique way that the root account and user account are related in maemo. On the surface it would seem as though you could simply issue a "sudo ./myscript" but I don't think that works out of the box in maemo. Hopefully some of the more seasoned maemo veterans will have an answer for the on-liner you are seeking to create.

One thing you *might* try is to setuid the script (chown file to root, and then chmod u+s the file) that does the things you want to do. You would then execute it as "user" but it would automagically run as root. Can provide a nice huge security hole in most unix systems, but with the "sudo gainroot" thing that doesn't even require a password, I'm not sure that's a concern in this particular case.
 

The Following User Says Thank You to texaslabrat For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 07:33.