![]() |
A equivilent of a .bat file on the n900?
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 |
Re: A equivilent of a .bat file on the n900
Code:
echo "#!/bin/bash" > powerlevel.sh |
Re: A equivilent of a .bat file on the n900
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 |
Re: A equivilent of a .bat file on the n900
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?
|
Re: A equivilent of a .bat file on the n900
Yes, you type in this in X Terminal:
Code:
echo "#!/bin/sh" > powerlevel.sh Code:
./powerlevel.sh |
Re: A equivilent of a .bat file on the n900
Code:
#!/bin/sh |
Re: A equivilent of a .bat file on the n900
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? |
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
is the problem that it should be entered as one line? My browser splits the part after the pipe onto a new line.
|
Re: A equivilent of a .bat file on the n900
Quote:
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. |
Re: A equivilent of a .bat file on the n900
i tried to do as you said qwerty but i can't get it working, i'm not sure what to try now, i think texas has summed it up nicely, i'll have to run it from root for now.
Is there a way to clear the contents of the powerlevel.sh file from x terminal? i accidentially but the command in the file once wrong. |
Re: A equivilent of a .bat file on the n900
Quote:
Code:
#!/bin/sh |
Re: A equivilent of a .bat file on the n900
Quote:
Well, this worked for me: Code:
#! /bin/sh |
Re: A equivilent of a .bat file on the n900
Quote:
That's the idea of the sudo system. |
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
You can use rootsh instead of sudo. For example: rootsh <command> will execute <command> as root.
|
Re: A equivilent of a .bat file on the n900
Quote:
1. Open up xterm. 2. In xterm type: vi powerlevel.sh 3. Press "i" key it will activate "Insert" mode. 4. Type as it is there (every line is a new line so there is enter after every line however, you don't press space in the front). 5. After you have finished typing everything, press the esc key and then ":" followed by "wq" (without double quotes) and hit enter. 6. It will save your file as powerlevel.sh in the same directory you are currently working. 7. Again in the xterm type: chmod +x powerlevel.sh 8. To execute: ./powerlevel.sh That's it. |
Re: A equivilent of a .bat file on the n900
Quote:
https://help.ubuntu.com/community/RootSudo A little verbose, but you can skim read to the parts relevant to you [and Maemo] |
Re: A equivilent of a .bat file on the n900
Quote:
I saw the sudoers.d dir but didn't get back to looking in there. I'll give it a peek. Thanks. |
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
On top, to make life more easier and thats what I did in my n810 but haven't tried it in n900 as I don't own it yet (but for different purpose), you can, according to this, create a .desktop file in /usr/share/applications/hildon and this will create an icon in the main menu which you can just click and get the job done. Easy :)
|
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
Quote:
I've done this and the file saved fine, i checked the contents with cat powerlevel.sh and it was correct, however when running it it doesn't change the powerlevel, any idea why? it looks fine to me and i did the chmod to, a message saying root enabled comes up when i run the file as user so it looks like its calling the correct file. On a side note when following your instructions i had to type sudo gainroot to run the commands, would this have caused a problem? |
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900
Quote:
http://talk.maemo.org/showpost.php?p...4&postcount=91 |
Re: A equivilent of a .bat file on the n900
Quote:
|
Re: A equivilent of a .bat file on the n900?
i did the following thing in xterminal without going in to sudo gainroot
Quote:
is it going to work when i write this command in xterm ./oc.sh EDIT: i tried this with the ./oc.sh command with and without sudo gainroot but an error is shown with " permission denied" can some body point oit my mistake, please. |
Re: A equivilent of a .bat file on the n900?
Permission denied usually means the executable bit is not set [you seemed to have taken care of that] or the underlying File System has noexec enabled, or it is a FAT or other weird FS.
Try Code:
sh oc.sh |
All times are GMT. The time now is 10:37. |
vBulletin® Version 3.8.8