The Following User Says Thank You to maxximuscool For This Useful Post: | ||
![]() |
2010-09-04
, 08:00
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#2
|
The Following User Says Thank You to maxximuscool For This Useful Post: | ||
![]() |
2010-09-04
, 08:11
|
Posts: 11 |
Thanked: 1 time |
Joined on Mar 2010
|
#3
|
import os os.system('echo 78 > /abc/abc/bca')
open('/abc/abc/bca', 'w').write('78')
![]() |
2010-09-04
, 09:09
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#4
|
You can't get root privileges inside the script: it is very insecure. You should write instead
or even betterCode:import os os.system('echo 78 > /abc/abc/bca')
and run this script with root privilegesCode:open('/abc/abc/bca', 'w').write('78')
The Following User Says Thank You to maxximuscool For This Useful Post: | ||
![]() |
2010-09-04
, 09:31
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#5
|
The Following User Says Thank You to maxximuscool For This Useful Post: | ||
![]() |
2010-09-04
, 10:08
|
Posts: 842 |
Thanked: 1,197 times |
Joined on May 2010
|
#6
|
![]() |
2010-09-04
, 10:38
|
|
Posts: 850 |
Thanked: 626 times |
Joined on Sep 2009
@ Vienna, Austria
|
#7
|
echo /path/to/script | sudo gainroot or /bin/busybox sh -c 'echo /path/to/script | sudo gainroot'
![]() |
2010-09-04
, 10:48
|
|
Posts: 3,159 |
Thanked: 2,023 times |
Joined on Feb 2008
@ Finland
|
#8
|
![]() |
2010-09-04
, 12:19
|
|
Posts: 850 |
Thanked: 626 times |
Joined on Sep 2009
@ Vienna, Austria
|
#9
|
#!/bin/sh
#!/usr/bin/python
![]() |
2010-09-04
, 14:44
|
Posts: 3,664 |
Thanked: 1,530 times |
Joined on Sep 2009
@ Hamilton, New Zealand
|
#10
|
to start a script as root, you could use
that script can be a shell script, python or anything else, as long as the executable flag (+x) is set.Code:echo /path/to/script | sudo gainroot or /bin/busybox sh -c 'echo /path/to/script | sudo gainroot'
(and just to mention it - there really is no point in using python if all you're doing are calls to os.system, better just use a shell script for that.)
Xterminal:
root
echo 78> /abc/abc/bca
i've tried this but nothing work.
If I run this from Xterminal as root:
root
python
import os
os.system('echo 78> /abc/abc/bca')
it works!
But if I run from script it doesnt. How can i get it to work?
The file is not changing.
How do I achieve this same effect with python?
Install Preenv games into eMMC| Click Here to get rid of Uboot screen
My N900 running at 250-1150Mhz
Unlocking your FM-transmitter to 76.0Mhz - 107.9Mhz range - CLICK HERE.
Last edited by maxximuscool; 2010-09-04 at 08:00.