Hacking android, got "system" user, but not root, how to escalate privilege? - Android Q&A, Help & Troubleshooting

Hacking android, got "system" user, but not root, how to escalate privilege?
Hello, i am new to XDA. I am trying to jail-break my android device:
Android 5.1.1, Linux 3.10.49
This device is a rare brand and have no any unlock & flash mechanism.
Currently i have successfully got "system" user (UID 1000) by using a preinstalled DEBUGGABLE system app.
This user can only change /data directory etc, it can not change any file owned by root.
So any help to escalate "system" user to root user will be very appreciate.
the result of command "id":
Code:
uid=1000(system)
gid=1000(system)
groups=1000(system)
1007(log)
1010(wifi)
1015(sdcard_rw)
1021(gps)
1023(media_rw)
1028(sdcard_r)
3001(net_bt_admin)
3002(net_bt)
3003(inet)
3004(net_raw)
3005(net_admin)
3006(net_bw_stats)
3009(qcom_diag)
9997(everybody)
41000(u0_a31000)
context=u:r:system_app:s0
This account can change /data/system/packages.xml etc, but can not change /system/*, nor chown/mount.....
It's CapBound is 0, too strict. And also can not disable SELinux.
Can anyone help me?
----------------------- PS: share how i get system user privilege, maybe helpful to others -----------------------
In a word, just use jdb to attache to the app then print new java.lang.Runtime().exec("sh /sdcard/my.sh").
First, i found a package appeared in Android Device Monitor's debuggable app list, e.x. com.example.app.
Then i use
Code:
pm dump com.example.app
got confirmed it use system UID, then
Code:
run-as com.example.app
but failed due to "Package not found", i don't know why.
Then i try to use JDWP way.
Get the debuggable process ID:
Code:
$ adb jdwp
9424
$ adb forward tcp:8600 jdwp:9424
$ jdb -attach localhost:8600
> threads
group system:
(java.lang.Thread)0x2a86 Signal Catcher ...
(java.lang.Thread)0x2a87 FinalizerWatchdogDaemon ...
...
group main:
(java.lang.Thread)0x2a8d main ...
(java.lang.Thread)0x2a8e Binder_1 ...
...
> thread 0x2a8d
main[1] stepi
>
stepi completed: "thread=main", android.os.MessageQueue.next()、row=145 bci=22
main[1] > print new java.lang.Runtime().exec("sh /sdcard/qj.sh")
There are some files need be upload(adb push .... ) before run the last command.
/sdcard/qj.sh:
Code:
date > /sdcard/log
cp -f /sdcard/busybox /data/ 2>> /sdcard/log || exit 1
chmod 4777 /data/busybox 2>> /sdcard/log || exit 1
(while true; do /data/busybox nc -l -p 7777 -e sh; done) >> /sdcard/log 2>&1 &
echo server OK >> /sdcard/log
/sdcard/busybox:
this file can be found at busybox.net/downloads/binaries/latest, choose ARM7v.
The above jdb command "print new java.lang.Runtime().exec("sh /sdcard/qj.sh")" will create a shell server listening at 7777 port, bridge input/output to sh.
So, to connect to the shell server,
Code:
adb forward tcp:7777 tcp:7777
nc localhost 7777
then in this connection, input shell command.
Sorry: i forgot a very important step: to run the "print new ...." statement, i have to turn on screen, even touch the app so can be trapped into jdb.
---------That's all------------

Related

[WIP] [DEV] [HOWTO] Ubuntu on Nook Color! UPDATE 1/5/11

DISCLAIMER: You know the risks, bricking, breaking etc. I'm not, nor is anyone else responsible if something goes wrong with your device, especially should it turn into a cave troll and bludgeon someone to death.
You will have to be rooted for this to work.
Update 1/5/11
Changed the install and loader scripts re-compressed and uploaded, new download link. Stream lined the installation process (removed 5 steps)
Update 1/4/11
reflect changes to ubuntu.sh and bootubuntu scripts and streamlining the process. Added screenshots
_________________________
I was over at nexusonehacks.net and looking at the ubuntu on nexus one hack and was thinking that this could be ported to the nook color. The idea is to run ubuntu from an img on the sd card.
The following is a modified version of the "how to" orginally posted here
http://nexusonehacks.net/nexus-one-hacks/how-to-install-ubuntu-on-your-nexus-oneandroid/
Credits
The guys at NexusOneHacks
xda user munday who has modified the scripts to work for the nook color
Devs at XDA Developer for the Ubuntu ARM image for HTC HD2
Saurik (Jay Freeman) for the Debian G1 script, which was hacked for Ubuntu on Nexus One! and then re-hacked for the Nook Color by munday
Here we go:
1) Go download the ubuntu file here: http://www.megaupload.com/?d=67BU4Y3T
2) Extract the contents using 7zip http://www.7-zip.org/download.html
3) Copy the extracted folder "ubuntu" to the root of your SD card
4) Unmount the nook from your pc, go into the app NookColor Tools (if you don't have it download it here courtesy of Ben 74 and click All Settings->Development then uncheck Auto Mount. This will prevent the SD card from being mounted automatically when plugged into the PC
5) Plug the Nook back into your pc and open a command line then navigate to your android sdk folder ie C:\android-sdk or wherever you have it and type
Code:
adb devices
Hit enter and make sure that the nook color comes up (should be the SN of your Nook)
Note: This can also be done from terminal emulator instead of adb...but it is kind of a pain
6) Now we want to go into the command line on the nook so type
Code:
adb shell
Hit enter and this should bring up a "#" sign.
7) Type
Code:
su
hit enter (I do this just as a force of habit)
8) Now we navigate to the ubuntu folder we just copied to our sd card by entering
Code:
cd /sdcard/ubuntu
hit enter. To confirm you are where you want to be you can type
Code:
ls
and it should list the contents of the ubuntu folder.
9) Run the setup script ubuntu.sh by entering the following:
Code:
sh ./ubuntu.sh
hit enter
10) Now type
Code:
bootubuntu
and hit enter
11) So now we have ubuntu command line up and running which should look like:
Code:
[email protected]:/#
We will need to get some packages to run a gui and then connect to it via VNC client. So we need to update a few things first. Type:
Code:
apt-get update
then
Code:
apt-get install tightvncserver
now we need the gui elements so enter this:
Code:
apt-get install lxde
12) Type the following:
Code:
export USER=root
vncserver -geometry 1024×600
this sets the resolution...you can change it to play around, but the native resolution for the nook is 1024x600. This is also where you will set the password for your vnc server...make sure to remember it
13) Next, we are going to add the following to /root/.vnc/xstartup file using cat command: (hit enter after each line and ignore the fact that it looks like it does it twice)
Code:
cat > /root/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
icewm &
lxsession
After hitting enter after the last line press "Ctrl+D" twice then press enter
14) We need the vnc server to start every time we start ubuntu, type this:
Code:
cat > front
export USER=root
cd /
rm -r -f tmp
mkdir tmp
cd /
vncserver -geometry 1024×600
Same as before, hit enter after each line then after hitting enter for the last line press "Ctrl+D" twice then press enter.
15) Enter this
Code:
cat front /root/.bashrc > temp
Then
Code:
cp temp /root/.bashrc
16) Now on the nook open up your vnc viewer app (android vnc viewer or PocketCloud...or whatever you use)
Use the following settings:
Host Address: 127.0.0.1 (some don't require this)
Password: the password you set up in step 16
Port: 5901
Save and then click connect and you should be up and running on ubuntu! To leave ubuntu type exit from adb. This should kill ubuntu. Exit adb and then you can disconnect the nook from your pc.
To start ubuntu from the nook open up a terminal emulater and type:
Code:
bootubuntu
Hit enter, this should bring up the [email protected], hhen press "Home" key and open up your vnc app. Now you are ready to rock your Linux tablet!
You could also use gscript lite to automate the process of starting ubuntu so you don't have to type it in the terminal everytime. You can get gscript lite from the market or download the file I have attached.
It does seem a little laggy..just a little...for now anyway
To exit ubuntu: Disconnect the vnc client then hold the "Home" key (I use button savior which brings up a nice little task manager) and click the Terminal emulator when it pops up under running tasks. Once you are back in the terminal you can type:
Code:
exit
to shut down ubuntu.
Enjoy and make sure you thank munday and the guys at nexusonehacks and all the devs who helped make it possible.
-devastator
EDIT:
I noticed that after rebooting the nook would hang at the "Future of reading" screen....if this happens turn the device off remove the sd card the turn the nook back on. It should boot fine. After it's finished you can return the sd card and mount it. This is strange and I'm looking into it. I'm not sure if this is limited to me or if it is universal to all nooks. It also still fails at shutting ubuntu down for some reason. I'm still looking into this.g into this.
I got it going, just needed a few "busybox"-es here and there . It needs some work, right now to get X you have to use VNC.
It's sluggish but a bit more work might just yield something a bit more usable. I'll play more tomorrow night.
Here's my scripts:
ubuntu.sh
Code:
mount -o remount,rw /dev/block/mmcblk0p5 /system
busybox modprobe ext2
rm -f /data/local/bin/fsrw
rm -f /data/local/bin/bootubuntu
rm -f /data/local/bin/unionfs
rm -f /data/local/bin/installer.sh
rm -f /data/local/bin/mountonly
mkdir /data/local/mnt
#busybox clear
rm /system/bin/fsrw
rm /system/bin/bootubuntu
rm /system/bin/unionfs
rm -/system/bin/mountonly
busybox cp -f fsrw /system/bin
busybox cp -f bootubuntu /system/bin
busybox cp -f unionfs /system/bin
busybox cp -f mountonly /system/bin
cd /sdcard/ubuntu
busybox chmod 4777 *
cd /system/bin/
busybox chmod 4777 *
cd /
#busybox clear
echo " "
echo "Ubuntu Chroot Bootloader v0.1"
echo "Ubuntu Bootloader is now installed!"
echo "This process does NOT damage Android OS!"
echo " "
echo "Original Installer by Charan Singh"
echo "Modified for Ubuntu Chroot by Max Lee at NexusOneHacks.net"
echo " "
echo "To enter the Debian Linux console just type 'bootubuntu'"
bootubuntu
Code:
mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
export mnt=/data/local/mnt
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
busybox mknod /dev/loop2 b 7 0
mount -o loop,noatime -t ext2 $kit/ubuntu.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "Setting localhost on /etc/hosts "
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "READY TO ROCK AND ROLL BABY! "
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo " "
busybox chroot $mnt /bin/bash
#After exit command is executed clear it all up
echo " "
echo "Shutting down Ubuntu"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
Then just followed the instructions at nexusonehacks.
note: to run bootubuntu i had to use sh and the use the full path:
Code:
# sh /system/bin/bootubuntu
other note: I was using adb not a term app on the nook.
Obligatory video
I can't post links yet so check: youtube.com/watch?v=TnXfZ6aagn8 for a really boring video
EDIT: switched the names, DOH!
I also had to use sh and the full path also. Thanks for the update on the script...gonna try it in the morning (it's 2am here) will also see if I can help to get it running smoother. What class SD card are you using? I imagine a class 4 or higher would yeild better results as far as responsiveness goes.
The sd is a class 2 that came in one of my dev phones. I'll pick up a faster one tomorrow after work and test it out.
It's just about 3am here now, we must be in the same time zone.
I'm going to bed now, but first here's a modded version of the script you had originally posted that also works now.
bootubuntu
Code:
#!/bin/sh
mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
busybox [ ! -d /data/local/ubuntu ] && mkdir /data/local/ubuntu
export mnt=/data/local/ubuntu
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
busybox mknod /dev/loop1 b 7 0
busybox losetup /dev/block/loop1 /sdcard/ubuntu/ubuntu.img
mount -t ext2 /dev/block/loop1 /data/local/ubuntu
#mount -o loop,noatime -t ext2 $kit/ubuntu.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "Setting localhost on /etc/hosts "
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "READY TO ROCK AND ROLL BABY! "
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo " "
busybox chroot $mnt /bin/bash
#After exit command is executed clear it all up
echo " "
echo "Shutting down Ubuntu"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
busybox losetup -d /dev/loop1
#unregistering the loopback device just seems to die. need to fix or remove.
I'll look at the N1 formus tomorrow too and see if they have made progress in getting X to run fast or without need for VNC.
Nice work, I am addicted in seeing the crazy crap people are doing everyday.
Couldn't sleep so I'm messing around with it now...I'm using a class 4 and have it up and running. It does seem to be a little laggy, but I don't have a class 2 to compare it to. Let me know what you find out, I'll keep playing with it also to see if I can get it to be more responsive...but we are definately on our way to having a great little linux tablet in addition to android. You should also be able to use this for other builds of linux also by just changing out the .img file to a flavor of your choosing. I'm excited
I have also updated the OP with the how to and credits. Really appreciate your help munday.
I noticed that after rebooting the nook would hang at the "Future of reading" screen....if this happens turn the device off remove the sd card the turn the nook back on. It should boot fine. After it's finished you can return the sd card and mount it. This is strange and I'm looking into it. I'm not sure if this is limited to me or if it is universal to all nooks.
Edit:
Running into some strange occurrences...it appears that when you type exit from the terminal to kill ubuntu, I believe ubuntu stays running...anyway, I'm going to bed and will work on it more tomorrow.
devastatorx said:
You should also be able to use this for other builds of linux also by just changing out the .img file to a flavor of your choosing. I'm excited
Click to expand...
Click to collapse
Are there any increased risks with changing the version you use?
Well, you will want to make sure that the build supports ARM based devices.
munday said:
Then just followed the instructions at nexusonehacks.
note: to run bootubuntu i had to use sh and the use the full path:
Code:
# sh /system/bin/bootubuntu
Click to expand...
Click to collapse
I fixed this, the scripts were backwards, I have updated the OP to reflect the changes and bootubuntu now works
devastatorx said:
I fixed this, the scripts were backwards, I have updated the OP to reflect the changes and bootubuntu now works
Click to expand...
Click to collapse
sweet, i can't wait to get home to play more!!!
I've tried running ubuntu.sh from the terminal emulator (With su) and from ADB, and have not had success with either.
The readout is:
Code:
': File existste '/system/bin
': File existste '/system/bin
': File existste '/system/bin
: not found
: not found
cd: can't cd to /sdcard/ubuntu
: not found
: No such file or directory
: not found
cd: can't cd to /system/bin
: not found
: No such file or directory
: not found
cd: can't cd to /
: not found
: not found
Ubuntu Chroot Bootloader v0.1
Ubuntu Bootloader is now installed!
etc., etc.
Is there a problem with how I copied the script? I assume the first part about the file existing is due to this being the third or fourth time I've tried running the script (Unsuccessfully), but I've no idea how to interpret the rest.
Thanks
munday said:
sweet, i can't wait to get home to play more!!!
Click to expand...
Click to collapse
I sent you a message
Link3737 said:
I've tried running ubuntu.sh from the terminal emulator (With su) and from ADB, and have not had success with either.
The readout is:
Code:
': File existste '/system/bin
': File existste '/system/bin
': File existste '/system/bin
: not found
: not found
cd: can't cd to /sdcard/ubuntu
: not found
: No such file or directory
: not found
cd: can't cd to /system/bin
: not found
: No such file or directory
: not found
cd: can't cd to /
: not found
: not found
Ubuntu Chroot Bootloader v0.1
Ubuntu Bootloader is now installed!
etc., etc.
Is there a problem with how I copied the script? I assume the first part about the file existing is due to this being the third or fourth time I've tried running the script (Unsuccessfully), but I've no idea how to interpret the rest.
Thanks
Click to expand...
Click to collapse
Try using these, just unrar and then copy them in your ubuntu folder, if it asks to overwrite just click yes...also you have autmounting of the sd card turnned off in nook color tools settings right?
Yeah, it must have been an error on my end. Using the updated scripts you posted worked like a charm.
Thanks!
Link3737 said:
Yeah, it must have been an error on my end. Using the updated scripts you posted worked like a charm.
Thanks!
Click to expand...
Click to collapse
Good to hear!
I'm currently working on making this a port to the SD card so that with the sd card in it boots into ubuntu from power off, and with the sd card out it boots to android then you replace the sd and use it for storage like normal. It will also run a lot snappier....well that's the idea anyway.
devastatorx said:
Good to hear!
I'm currently working on making this a port to the SD card so that with the sd card in it boots into android from power off, and with the sd card out it boots to android then you replace the sd and use it for storage like normal. It will also run a lot snappier....well that's the idea anyway.
Click to expand...
Click to collapse
Booting from SD in the same fashion as Nookie Froyo? That sounds like it would give a huge performance boost over the current method, I can't wait to see what you come up with.
This should be acheivable using the method mentioned in this topic:
http://forum.xda-developers.com/showthread.php?t=873243 thanks to clockworx.
Currently looking into this
devastatorx said:
This should be acheivable using the method mentioned in this topic:
http://forum.xda-developers.com/showthread.php?t=873243 thanks to clockworx.
Currently looking into this
Click to expand...
Click to collapse
I was thinking the exact same thing, the nook seems to like booting from sd, so we should be able to set up the partitions like the foryo sd and edit the init.rc and env.txt to boot ubuntu instead of android. Just a theory though. It's my plan for tonight anyway.
munday said:
I was thinking the exact same thing, the nook seems to like booting from sd, so we should be able to set up the partitions like the foryo sd and edit the init.rc and env.txt to boot ubuntu instead of android. Just a theory though. It's my plan for tonight anyway.
Click to expand...
Click to collapse
I also stumbled across this: http://androix.org/ Which talks about a native android xserver which does a way with the vnc aspect altogether. I downloaded and attempted to install but I get the error "There is a problem parsing the package" and I haven't had any luck plus there isn't much documentation.
Let me know how it goes munday, I'll be working on the same thing later (have to take the fiance out for dinner)
question
I was just curious, after installing ubuntu can we install flash as we would had we booted linux from netbook?

[Q] Help with ADB or rather a simple command. Im confused!!

Ok, so basically Im trying to extract data from my contacts2.db file.
Ive managed to copy it out of the hidden data folder on my GalaxySII onto my PC HDD. Now i need to run a script to extract the data. The thing is, im baffled how to do this.
Im a n00b when it comes to ADB, but i managed to drop the script and the copied contact2.db file into a test folder on my device, i managed to use the terminal emulator to browse to the directory and run the command but I get: 'Permission Denied' when I run the script. Ive tried changing the permissions on the file via my SII but to no avail.
So, im following the instructions I have via my PC:
== Usage ==
Copy your Android contacts database to your computer:
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db ./
Run this file from the same directory as contacts2.db
./fb-extract.sh
Import csv to an address book of your choice
Now ive got the db, but how do I run the script. Ive tried to load adb emulator but have no idea what im doing there. Ive tried to use the adb command but again, no idea.
Can someone give me a brief, and quick step-by-step way to run this script on my contacts file so I can extract the data I want please.
Thanks muchly....
-=stylus=-
What are you trying to accomplish? The instructions say you should be running the shell script on the PC, not the phone. But you can't just natively run shell scripts in Windows, which I presume is what you're using. You'd need Cygwin or similar assuming you're averse to Linux, and possibly other stuff, depending on what the script is doing.
That fb-script you're trying to run is probably extracting the data with sqlite3. So you need to have the sqlite3 binary available where you are running the script (phone or computer). There are many things which can go wrong, first step would be to paste the content of fb-extract.sh here.
Ah, yes sorry. Im trying to extract all email addresses from my contacts on my phone. Facebook syncs with your Android device and adds all the email addresses registered with your contacts.
The script I have should extract all this data out:
(Not sure if Im allow to post code but)
#! /bin/sh
###########################################
#
# Android DB contacts exporter (proof-of-concept)
# 2011-01-06
#
# Extracts "certain contacts" from the Android contacts database to a CSV file
# for import into other contact list tools.
#
#
# == Usage ==
#
# 1) Copy your Android contacts database to your computer
# adb pull /data/data/com.android.providers.contacts/databases/contacts2.db ./
# 2) Run this file from the same directory as contacts2.db
# ./fb-extract.sh
# 3) Import csv to an address book of your choice
#
# == Notice ==
#
# This is a proof of concept script. Use at your own risk and check
# with laws and terms of service regarding data usage.
#
###########################################
# In and out files
CONTACTSDB="./contacts2.db"
OUTFILE="./contacts_fb.csv"
# Write table header
echo "First Name,Last Name,E-mail Address,Mobile Phone,Home Phone" >> $OUTFILE
# Get the raw IDs of all facebook contacts
RAWID_LIST=`sqlite3 $CONTACTSDB "SELECT _id from raw_contacts WHERE account_type='com.facebook.auth.login'"`
# Loop through the IDs and extract necessary data
for RAWID in $RAWID_LIST; do
# Get the first and last names
NAME=`sqlite3 $CONTACTSDB "SELECT data2, data3 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=7"`
FNAME=`echo $NAME | awk '{split($0,a,"|"); print a[1]}'`
LNAME=`echo $NAME | awk '{split($0,a,"|"); print a[2]}'`
# Get the email address
EMAIL=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=1"`
# Get the phone numbers (mobile & other). Convert international Japanese # to local using `sed`
MPHONE=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=5 AND data2=2" | sed 's/^81\([0-9]\{7,\}\)/0\1/'`
OPHONE=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=5 AND data2=7" | sed 's/^81\([0-9]\{7,\}\)/0\1/'`
# If at least one info field was set then write the csv line
if [ -n "$EMAIL" ] || [ -n "$MPHONE" ] || [ -n "$OPHONE" ]; then
echo "$FNAME,$LNAME,$EMAIL,$MPHONE,$OPHONE" >> $OUTFILE
fi
done
Now like I said, I have the contacts2.db file, I just am not sure how to go about running this script on it to accomplish my task.
I understand a bit of coding but not much so bear with me.
-=stylus=-
Well, it's obvious you have to run it on a Linux/Android system with /bin/sh and sqlite3 binaries. So, probably better to run it on your phone. But first, you need to have the sqlite3 binary from somewhere, as it's not shipped by default.
Get SuperOneClick and extract it; in the Dependencies folder you'll find the sqlite3 file.
Push it to the phone from your computer (these commands are run in command prompt):
Code:
C:\> adb remount /system
C:\> adb push /path/to/sqlite3 /system/xbin/sqlite3
Check the sqlite3 binary is present in the system path and available:
Code:
C:\> adb shell
[email protected]# which sqlite3
/system/xbin/sqlite3
Now you can run your script. With adb shell, run the script on your phone in the same folder where you have the .db file. Should create a new CSV file which can be pulled to your computer.
Now i just get the error message:
./fb-extract.sh: cannot execute - permission denied
chmod 777 fb-extract.sh
Depending on what folder you're in, you may need to remount r/w too.
And make sure you're not having the two files on a partition mounted with noexec
I wish I was good at this stuff....
Ok, its in a folder:
/sdcard/test
contents of this folder are:
contacts2.db
fb-extract.sh
Ive run the 'chmod 777 fb-extract.sh' command but still permission denied.
Should I put it in a different folder and run it? Is there a better way?
Sorry for my lack of knowledge here but no idea what remount r/w (well other than remount read/write) is or how to do it. How do I know if ive got it on a partition mounted with noexec?
In "adb shell":
Code:
[email protected] # mount | grep sdcard
and post the output. If you see a "noexec" flag, then it doesn't allow you to exec anything from the sdcard. You could try after that
Code:
[email protected] # mount -o remount,exec /sdcard
and try the script again.
I think im losing the will to live guys ha ha ha!!!
Ok the output was:
Code:
a/local/bin:$PATH <
[email protected]:/ $ su
[email protected]:/ # mount | grep sdcard
/dev/block/vold/259:3 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/external_sd type tmpfs (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,size=0k,mode=755,gid=1000)
tmpfs on /mnt/sdcard/usbStorage type tmpfs (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,size=0k,mode=755,gid=1000)
/dev/block/vold/179:25 on /mnt/sdcard/external_sd type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,uid=1000,gid=1023,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/external_sd/.android_secure type tmpfs (ro,relatime,size=0k,mode=000) [email protected]:/ # mount -o remount,exec /sdcard
mount: can't find /sdcard in /proc/mounts
1|[email protected]:/#
Now im doing all this using terminal emulator on my phone. Thats the same as adb right? Still getting permission denied though.
You would think extracting email addresses from your contacts list was easy!
/mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec
This is what I was saying before.
On your phone with adb:
Code:
[email protected] # mount -o rw,remount /mnt/sdcard
and then you should be able to execute the script.
Well, it's difficult because it wasn't designed to be used that way (although what you are trying to do is quite simple). It would have been easier to sync your contacts with Google and download the CSV from Google Contacts' web interface.
Nope. Still cant do it.. still permission denied.
I cant sync with Google, create a vcard or anything. The facebook emails are protected somehow. If you export your contacts list to any file, it leaves all the facebook emails out!
Agghhhhhhh!
Thanks for all your help though. Much appreciated!!!

[Q] My code doesn't run in init.rc

how can I solve that problem?
I write the code in init.rc:
Code:
mv /com.anddoes.launcher_preferences.xml /data/data/com.anddoes.launcher/shared_prefs/
it returns such error:
<3>[ 0.640121] init: /init.rc: 351: invalid command 'mv'​
I tried both to write a script and to move toolbox with mv to the system root, but it returns the same error.
All the necessary folders exist
MaxiManBW said:
how can I solve that problem?
I write the code in init.rc:
Code:
mv /com.anddoes.launcher_preferences.xml /data/data/com.anddoes.launcher/shared_prefs/
it returns such error:
<3>[ 0.640121] init: /init.rc: 351: invalid command 'mv'​
I tried both to write a script and to move toolbox with mv to the system root, but it returns the same error.
All the necessary folders exist
Click to expand...
Click to collapse
init.rc is not a shell script, but a command language for the init process. Use can use the "exec" command to execute the mv command, see the docs below. Remember to use full paths.
Code:
Android Init Language
---------------------
The Android Init Language consists of four broad classes of statements,
which are Actions, Commands, Services, and Options.
All of these are line-oriented, consisting of tokens separated by
whitespace. The c-style backslash escapes may be used to insert
whitespace into a token. Double quotes may also be used to prevent
whitespace from breaking text into multiple tokens. The backslash,
when it is the last character on a line, may be used for line-folding.
Lines which start with a # (leading whitespace allowed) are comments.
Actions and Services implicitly declare a new section. All commands
or options belong to the section most recently declared. Commands
or options before the first section are ignored.
Actions and Services have unique names. If a second Action or Service
is declared with the same name as an existing one, it is ignored as
an error. (??? should we override instead)
Actions
-------
Actions are named sequences of commands. Actions have a trigger which
is used to determine when the action should occur. When an event
occurs which matches an action's trigger, that action is added to
the tail of a to-be-executed queue (unless it is already on the
queue).
Each action in the queue is dequeued in sequence and each command in
that action is executed in sequence. Init handles other activities
(device creation/destruction, property setting, process restarting)
"between" the execution of the commands in activities.
Actions take the form of:
on <trigger>
<command>
<command>
<command>
Services
--------
Services are programs which init launches and (optionally) restarts
when they exit. Services take the form of:
service <name> <pathname> [ <argument> ]*
<option>
<option>
...
Options
-------
Options are modifiers to services. They affect how and when init
runs the service.
critical
This is a device-critical service. If it exits more than four times in
four minutes, the device will reboot into recovery mode.
disabled
This service will not automatically start with its class.
It must be explicitly started by name.
setenv <name> <value>
Set the environment variable <name> to <value> in the launched process.
socket <name> <type> <perm> [ <user> [ <group> ] ]
Create a unix domain socket named /dev/socket/<name> and pass
its fd to the launched process. <type> must be "dgram", "stream" or "seqpacket".
User and group default to 0.
user <username>
Change to username before exec'ing this service.
Currently defaults to root. (??? probably should default to nobody)
Currently, if your process requires linux capabilities then you cannot use
this command. You must instead request the capabilities in-process while
still root, and then drop to your desired uid.
group <groupname> [ <groupname> ]*
Change to groupname before exec'ing this service. Additional
groupnames beyond the (required) first one are used to set the
supplemental groups of the process (via setgroups()).
Currently defaults to root. (??? probably should default to nobody)
oneshot
Do not restart the service when it exits.
class <name>
Specify a class name for the service. All services in a
named class may be started or stopped together. A service
is in the class "default" if one is not specified via the
class option.
onrestart
Execute a Command (see below) when service restarts.
Triggers
--------
Triggers are strings which can be used to match certain kinds
of events and used to cause an action to occur.
boot
This is the first trigger that will occur when init starts
(after /init.conf is loaded)
<name>=<value>
Triggers of this form occur when the property <name> is set
to the specific value <value>.
device-added-<path>
device-removed-<path>
Triggers of these forms occur when a device node is added
or removed.
service-exited-<name>
Triggers of this form occur when the specified service exits.
Commands
--------
exec <path> [ <argument> ]*
Fork and execute a program (<path>). This will block until
the program completes execution. It is best to avoid exec
as unlike the builtin commands, it runs the risk of getting
init "stuck". (??? maybe there should be a timeout?)
export <name> <value>
Set the environment variable <name> equal to <value> in the
global environment (which will be inherited by all processes
started after this command is executed)
ifup <interface>
Bring the network interface <interface> online.
import <filename>
Parse an init config file, extending the current configuration.
hostname <name>
Set the host name.
chdir <directory>
Change working directory.
chmod <octal-mode> <path>
Change file access permissions.
chown <owner> <group> <path>
Change file owner and group.
chroot <directory>
Change process root directory.
class_start <serviceclass>
Start all services of the specified class if they are
not already running.
class_stop <serviceclass>
Stop all services of the specified class if they are
currently running.
domainname <name>
Set the domain name.
insmod <path>
Install the module at <path>
mkdir <path> [mode] [owner] [group]
Create a directory at <path>, optionally with the given mode, owner, and
group. If not provided, the directory is created with permissions 755 and
owned by the root user and root group.
mount <type> <device> <dir> [ <mountoption> ]*
Attempt to mount the named device at the directory <dir>
<device> may be of the form [email protected] to specify a mtd block
device by name.
<mountoption>s include "ro", "rw", "remount", "noatime", ...
setkey
TBD
setprop <name> <value>
Set system property <name> to <value>.
setrlimit <resource> <cur> <max>
Set the rlimit for a resource.
start <service>
Start a service running if it is not already running.
stop <service>
Stop a service from running if it is currently running.
symlink <target> <path>
Create a symbolic link at <path> with the value <target>
sysclktz <mins_west_of_gmt>
Set the system clock base (0 if system clock ticks in GMT)
trigger <event>
Trigger an event. Used to queue an action from another
action.
write <path> <string> [ <string> ]*
Open the file at <path> and write one or more strings
to it with write(2)
Properties
----------
Init updates some system properties to provide some insight into
what it's doing:
init.action
Equal to the name of the action currently being executed or "" if none
init.command
Equal to the command being executed or "" if none.
init.svc.<name>
State of a named service ("stopped", "running", "restarting")
Example init.conf
-----------------
# not complete -- just providing some examples of usage
#
on boot
export PATH /sbin:/system/sbin:/system/bin
export LD_LIBRARY_PATH /system/lib
mkdir /dev
mkdir /proc
mkdir /sys
mount tmpfs tmpfs /dev
mkdir /dev/pts
mkdir /dev/socket
mount devpts devpts /dev/pts
mount proc proc /proc
mount sysfs sysfs /sys
write /proc/cpu/alignment 4
ifup lo
hostname localhost
domainname localhost
mount yaffs2 [email protected] /system
mount yaffs2 [email protected] /data
import /system/etc/init.conf
class_start default
service adbd /sbin/adbd
user adb
group adb
service usbd /system/bin/usbd -r
user usbd
group usbd
socket usbd 666
service zygote /system/bin/app_process -Xzygote /system/bin --zygote
socket zygote 666
service runtime /system/bin/runtime
user system
group system
on device-added-/dev/compass
start akmd
on device-removed-/dev/compass
stop akmd
service akmd /sbin/akmd
disabled
user akmd
group akmd
Debugging notes
---------------
By default, programs executed by init will drop stdout and stderr into
/dev/null. To help with debugging, you can execute your program via the
Andoird program logwrapper. This will redirect stdout/stderr into the
Android logging system (accessed via logcat).
For example
service akmd /system/bin/logwrapper /sbin/akmd
kuisma said:
init.rc is not a shell script, but a command language for the init process. Use can use the "exec" command to execute the mv command, see the docs below. Remember to use full paths.
Code:
Android Init Language
---------------------
The Android Init Language consists of four broad classes of statements,
which are Actions, Commands, Services, and Options.
All of these are line-oriented, consisting of tokens separated by
whitespace. The c-style backslash escapes may be used to insert
...........................................
Click to expand...
Click to collapse
I created script and put it to /system folder
Then call it with:
Code:
service my_script /system/my_script.sh
class main
oneshot
and again received an error: <3>[ 61.921627] init: cannot find '/system/my_script.sh', disabling 'my_script'
MaxiManBW said:
I created script and put it to /system folder
Then call it with:
Code:
service my_script /system/my_script.sh
class main
oneshot
and again received an error: <3>[ 61.921627] init: cannot find '/system/my_script.sh', disabling 'my_script'
Click to expand...
Click to collapse
Is you script executable and begins with the line "#!/system/bin/sh"?
kuisma said:
Is you script executable and begins with the line "#!/system/bin/sh"?
Click to expand...
Click to collapse
Yes!
just in case, I used chmod 777 and first line begins with the line "#!/system/bin/sh".
Error no longer appears, but script doesn't work:
Code:
#!/system/bin/sh
if [-a /com.anddoes.launcher_preferences.xml]
cp /com.anddoes.launcher_preferences.xml /data/data/com.anddoes.launcher/shared_prefs/
rm /com.anddoes.launcher_preferences.xml
fi
I may be wrong calling service?
Code:
service my_script /system/my_script.sh
class main
oneshot
MaxiManBW said:
Yes!
just in case, I used chmod 777 and first line begins with the line "#!/system/bin/sh".
Error no longer appears, but script doesn't work:
Code:
#!/system/bin/sh
if [-a /com.anddoes.launcher_preferences.xml]
cp /com.anddoes.launcher_preferences.xml /data/data/com.anddoes.launcher/shared_prefs/
rm /com.anddoes.launcher_preferences.xml
fi
I may be wrong calling service?
Code:
service my_script /system/my_script.sh
class main
oneshot
Click to expand...
Click to collapse
I guess cp works, but not rm? Root is remounted read-only quite early in init.rc
Edit: Also, I've told you to use full paths. And that if-syntax...? It's sure not standard shell test syntax.
MaxiManBW said:
how can I solve that problem?
I write the code in init.rc:
Code:
mv /com.anddoes.launcher_preferences.xml /data/data/com.anddoes.launcher/shared_prefs/
it returns such error:
<3>[ 0.640121] init: /init.rc: 351: invalid command 'mv'​
I tried both to write a script and to move toolbox with mv to the system root, but it returns the same error.
All the necessary folders exist
Click to expand...
Click to collapse
Did it work?
I think init.rc only understands absolute paths... I mean, replacing mv with the below might work.
/system/bin/mv XXX YYY
-pradeep.
---------- Post added at 03:41 PM ---------- Previous post was at 03:16 PM ----------
kuisma said:
I guess cp works, but not rm? Root is remounted read-only quite early in init.rc
Edit: Also, I've told you to use full paths. And that if-syntax...? It's sure not standard shell test syntax.
Click to expand...
Click to collapse
I have a similar question regarding init.rc.
I am trying to run a native application (which downloads the wifi firmware to dongle). I need this to be done before the wifi driver module is insmod'ed. Accordingly, I have an entry in init.rc with 'exec' command to run it -- at the end of "on init" section.
exec /system/bin/downloader -n /system/etc/wifi/xyz.nvm /system/etc/wifi/fake.trx
This command doesn't seem to run although I don't see any errors in the boot log.
I also tried a combination of 'service' commands like:
service downloader /system/bin/downloader -n /system/etc/wifi/xyz.nvm /system/etc/wifi/fake.trx
disabled
oneshot
Same result: no error in the bootlog but firmware not downloaded.
Any idea what might be wrong with the commands here? I am on JB-MR1.
-pradeep.
Gurumath said:
Did it work?
I think init.rc only understands absolute paths... I mean, replacing mv with the below might work.
/system/bin/mv XXX YYY
-pradeep.
---------- Post added at 03:41 PM ---------- Previous post was at 03:16 PM ----------
I have a similar question regarding init.rc.
I am trying to run a native application (which downloads the wifi firmware to dongle). I need this to be done before the wifi driver module is insmod'ed. Accordingly, I have an entry in init.rc with 'exec' command to run it -- at the end of "on init" section.
exec /system/bin/downloader -n /system/etc/wifi/xyz.nvm /system/etc/wifi/fake.trx
This command doesn't seem to run although I don't see any errors in the boot log.
I also tried a combination of 'service' commands like:
service downloader /system/bin/downloader -n /system/etc/wifi/xyz.nvm /system/etc/wifi/fake.trx
disabled
oneshot
Same result: no error in the bootlog but firmware not downloaded.
Any idea what might be wrong with the commands here? I am on JB-MR1.
-pradeep.
Click to expand...
Click to collapse
So here is the thing I read somewhere that exec are just added for show and they don't actually work
I am not entirely sure of the above statement, but what I am sure of is that you can write a script and add it to the init.rc to get your work done
---------- Post added at 10:26 AM ---------- Previous post was at 10:16 AM ----------
kuisma said:
I guess cp works, but not rm? Root is remounted read-only quite early in init.rc
Edit: Also, I've told you to use full paths. And that if-syntax...? It's sure not standard shell test syntax.
Click to expand...
Click to collapse
It is not about the wrong service being called.
It is the fact that the service has been defined but you need to call the service at some instant by adding the command
'start yourServiceName'
That is if you want to start your service at boot time, you will need to add the following lines
on property:sys.boot_completed=1
start my_script
Here is a full version of a script that I wrote, this was to toggle wifi at regular interval of time
My Shell Script - init.custom.sh
#!/system/bin/sh
while true; do
svc wifi disable
sleep 10
svc wifi enable
sleep 60
done
My Code inside init.rc
service custom /system/bin/init.custom.sh
user root
oneshot
on property:sys.boot_completed=1
write /sys/block/mmcblk0/queue/scheduler cfq ## This was already present
start custom
I know this is a very late reply, but I started exploring these things recently.
Hope this helps someone.

[HOW TO] Install/Run Android SDK 64 Bit Native on Device

I learned about this here... http://fieldeffect.info/w/NativeCompileSDK
You can install an i386/x86_64 chroot within your existing Debian chroot using qemu-user-static to run the Android SDK on your Android phone/tablet/phablet.
1.
Get yourself a debian chroot, I recommend at least 2gb. I use DebianKit from market.
2.
You will need a X11 desktop environment and a VNC client on your device. I use androidVNC from market.
Here is my working example...
Start your Debian chroot/environment and do...
apt-get install openbox openbox-themes obmenu obconf menu menu-xdg xdg-utils xfonts-base xfonts-terminus* nautilus terminator lxappearance gmrun leafpad man-db hicolor-icon-theme tightvncserver tint2
That gives you a window manager, fonts, filebrowser, terminal emulator, text editor, theme manager, taskbar, and a VNC server.
Now lets get some GTK engines and libraries....
apt-get install gtk2-engines-auroa gtk2-engines-murrine gtk2-engines-oxygen gtk2-engines-pixbuf libgtk2.0-bin gtk3-engines-oxygen gtk3-engines-unico libgtk-3-bin
Now 7zip to handle zips and archives comfortably(put non-free in your apt sources.list)...
apt-get install p7zip p7zip-full p7zip-rar zip unzip
##The Android SDK manager, qemu, and multistrap##
apt-get install ant file openjdk-6-jre openjdk-6-jdk qemu-user-static libswt-gtk-3-java libswt-cairo-gtk-3-jni
3.
Now we can build a small x86_64 rootfs using multistrap
multistrap can use a config, have mine...
http://db.tt/hS5j3wg
Copy multistrap.conf straight into your working(pwd) directory....
cp /sdcard/Download/multistrap.conf .
Do this to avoid multistrap complaining later...
cat multistrap.conf >mstrap
mkdir /data/mnt
Determine size of rootfs for loop image..
du -hs /data/mnt/
Now make an image for x86_64 chroot
dd if=/dev/zero of=/sdcard/64bit.img bs=$(( 0x100000 )) count=YOUR IMAGE SIZE
That byte size makes your image slightly larger than the count value in Mb, for example count=78 will write 82Mb image.
mkfs.ext2 /sdcard/64bit.img
tune2fs -c0 /sdcard/64bit.img
mkdir /data/tmp
busybox mount -o loop /sdcard/64bit.img /data/tmp/
cp -r /data/mnt/* /data/tmp/
umount /data/tmp
rm -r /data/tmp/
rm -r /data/mnt/
mkdir /data/mnt
busybox mount -o loop /sdcard/64bit.img /data/mnt/
5.
Now the environment is set up and mounted, at this point install the SDK
Aim your browser to http://developer.android.com/sdk/index.html
Select "Linux" from "SDK Tools Only", thats the last thing at the bottom of the list.
cp /sdcard/Download/android-sdk_r21.0.1-linux.tgz .
7z x android-sdk_r21.0.1-linux.tgz russosv
7z x android-sdk_r21.0.1-linux.tar
Now we need a couple goodies from http://fieldeffect.info/w/NativeCompileAPK ##--Thanks to russosv from FeildEffect
These are edited from original....
#!/bin/bash
QEMU=/usr/bin/qemu-x86_64-static
64CHROOT=/data/mnt/
case "$1" in
mklinks)
if [ ! -e "./64BIT" ]; then
mkdir ./64BIT
fi
for i in $(file ./* | grep "ELF 32" | awk '{print $1}' | sed s/://g | sed s/[./]//g); do
echo "Moving $i..."
mv $i ./64BIT
ln -s ~/bin/run-64-link $i
done-
;;
*)
$QEMU $64CHROOT/lib64/ld-linux-x86_64.so.2 --library-path $64CHROOT/lib:$64CHROOT/usr/lib:$64CHROOT/usr/share/perl/5.12.4/unicore/lib:$64CHROOT/var/lib:$64CHROOT/lib/x86_64-linux-gnu:$64CHROOT/usr/lib/x86_64-linux-gnu [email protected]
;;
esac
Copy that to run-64, then...
chmod 755 run64
cp run-64 /usr/bin/
One more...
echo $(dirname $0)/64BIT/$(basename $0) [email protected]
/usr/bin/run-i386 $(dirname $0)/64BIT/$(basename $0) [email protected]
Make that run-64-link
chmod 755 run-64-link
cp run-64-link /usr/bin/
5b.
Now launch VNC server
tightvncpasswd
tightvncserver
killall Xtightvnc
cat >.vnc/xstartup<<EOF
tint2 &
terminator &
openbox-session
EOF
tightvncserver
export DISPLAY=:1
6.
Now launch the VNC client I mentioned earlier, should connect with 127.0.0.1:5901 and your password you set.
Go back to terminal or use the one launched on X11 to do...
sh android-sdk-linux/tools/android
Install at least one api.
If all went well you can now go around "debugging" yours and your friends Android devices over wifi now.
For an example, and to see it work do....
svc wifi disable(or enable) ##this turns off/on wifi
setprop service.adb.tcp.port 5555(or -1) ##this turns on/off adb over network
stop adbd
start adbd
adb connect 127.0.0.1(yours) or any other adbd addy listening on your network,
Have fun
Never did a "how to" before, go easy and I'll make corrections and answer things. Thanks for reading. Leave feedback.
Potential necro post but I believe the information is still currently valid and not readily available on searches. I've looked variations of this up for years with no luck until I hit the right search terms.
bump, and thanks.
can't believe there's no comments.
I know it's a slower than real-64-bit-pc method but not all of us have access to new hardware... or pc's. Maybe a novelty, still cool and useful if you've got the time to let the slower hardware compile.
you have preserved the scripts, original link is dead.
here is the Internet Wayback Machine cache of the original circa 2012 for reference.
http://web.archive.org/web/20120502044700/http://fieldeffect.info/w/NativeCompileAPK
appreciate you sharing.

[Q] adb works but not extract-files.sh

I am trying to extract vendor files from an i8730 phone using extract-files.sh
I have Linux Mint 14 with android-tools-adb installed as the adb
adb works fine to a point
[email protected] ~ $ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
333398202BDF00EC device
adb shell and ls shows files on the phone including the vendor folder
If I run ls from my working directly I can see extract-files.sh
Think the solution is in .bashrc but believe I am not doing it right. When I run extract-files.sh I get this
[email protected] ~ $ ./extract-files.sh
bash: ./extract-files.sh: Permission denied
[email protected] ~ $ sudo extract-files.sh
[sudo] password for megan:
sudo: extract-files.sh: command not found
[email protected] ~ $ sudo./extract-files.sh
bash: sudo./extract-files.sh: No such file or directory
location adb shows
/usr/share/doc/android-tools-adb
location bashrc shows
/etc/bash.bashrc
I have edit bashrc
[email protected] ~ $ sudo gedit /etc/bash.bashrc
[sudo] password for megan:
Have added this to the end
export PATH=${PATH}:/home/megan/usr/share/doc/android-tools-adb
Think this is where I have gone wrong. Any suggestions?
Thanks
Bazzan
http://forum.xda-developers.com/showpost.php?p=7146410&postcount=5
unable to create 99-android.rules
MoonBlade said:
http://forum.xda-developers.com/showpost.php?p=7146410&postcount=5
Click to expand...
Click to collapse
Thanks MoonBlade. Think you are suggesting the version on the link so have been working through it. Had to source the files elsewhere as original link is dead. May or may not be a problem.
Got as far as creating the file in /etc/udev/rules.d/ but am unable to create a file in that folder. I am logged in as root. I can view the folder through GUI but not able to create 99-android.rules
Get this mess in terminal
[email protected] ~ $ su
Password:
megan-901 megan # cd /etc/udev/rules.d/
megan-901 rules.d # ls
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 21, in <module>
os.execvp("python3", [sys.argv[0]] + sys.argv)
File "/usr/lib/python2.7/os.py", line 344, in execvp
_execvpe(file, args)
File "/usr/lib/python2.7/os.py", line 380, in _execvpe
func(fullname, *argrest)
OSError: [Errno 2] No such file or directory
megan-901 rules.d #
Not sure the above is anything to do with not being able to write to that folder. Any ideas?
Bazzan
ok im not sure exactly what youre trying to do but it sounds like you want to get files from your phones /vendor/ directory and copy them to a directory on your computer. if this is correct then you need to stop playiing around with your .bashrc and your $PATH appends. all you need to use is adb
you dont have to adb shell. once you run adb shell it opens up a terminal inside your device so if youre trying to run a shell script on your computer from inside an adb shell it just wont work.
a simpler way to put this is, if you want to get /vendor/firmware/bcm4329.bin from your phone and put it on your computer in a folder on your desktop you would run it like this
$adb pull /vendor/firmware/bcm4329.bin /home/megan/Desktop/phonevendorfirmware/bcm439.bin
and the directory and file will automatically be created on your computer. from there you can do what ever you wanted to do to the files that you pulled from the phone.
the same works in reverse if you want to move a file to the phone using $adb push
bazzan said:
[email protected] ~ $ ./extract-files.sh
bash: ./extract-files.sh: Permission denied
Click to expand...
Click to collapse
You need to give execution permissions to the script, this way:
Code:
chmod +x extract-files.sh
And then, run your script like this (if the script doesn't need root permissions, run it without sudo):
Code:
sudo ./extract-files.sh
Many thanks haxin and RoberGalarga
I was given the extract-files.sh by a developer to extract vendor files for ROM development - i8730. He did not have the phone (I don't at the moment as has been wrapped for the kids to give to me for my birthday - practicing on an a Galaxy S)
From peeking inside the file it looks like a batch file that grabs all the content from the vendor folder. Did SQL 10 years ago and looks like that. Essentially does what you gave me haxim, but pulls the content of the entire folder. What is the best way to do that with adb pull?
Gave chmod +x extract-files.sh a try.
Without sudo I get
bash:./extract-files.sh : /bin/sh^M: bad interpreter: No such file or directory
With sudo
sudo: unable to execute ./extract-files.sh: No such file or directory.
Remember I am running this against a i9000, not the phone that I was given the sh file to run against. Get that back the begining of September. Not sure if that makes a difference but if it does not obvious to me.Seems to be falling over on the first line as that appears in the non sudo error message.
Have copied the content of extract-files.sh below.
Thanks again guys. Learning heaps and loving it.
Bazzan
#!/bin/sh
set -e
export DEVICE=express
export VENDOR=samsung
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 1 ]; then
SRC=$1
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $BASE/*
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
echo "Extracting /system/$FILE ..."
DIR=`dirname $FILE`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "$SRC" = "adb" ]; then
adb pull /system/$FILE $BASE/$FILE
else
cp $SRC/system/$FILE $BASE/$FILE
fi
done
./setup-makefiles.sh
Where did you get the script? This error:
bazzan said:
bash:./extract-files.sh : /bin/sh^M: bad interpreter: No such file or directory
Click to expand...
Click to collapse
is caused by a bad formatting in the file (Window$ editing... pfff....), so, make a new file using Gedit and paste this directly (don't copy&paste from the original script!!):
bazzan said:
#!/bin/sh
set -e
export DEVICE=express
export VENDOR=samsung
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 1 ]; then
SRC=$1
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $BASE/*
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
echo "Extracting /system/$FILE ..."
DIR=`dirname $FILE`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "$SRC" = "adb" ]; then
adb pull /system/$FILE $BASE/$FILE
else
cp $SRC/system/$FILE $BASE/$FILE
fi
done
Click to expand...
Click to collapse
Delete the old file, and try the new one (you can use any filename, it doesn't matter).
Many thanks RoberGalarga.
Got the script off a recognised developer along with proprietary-files.txt and setup-makefiles.sh
He is working a CWM and a rom for owners of the i8730 - he does not have the phone so community feed in content. Get the impression he is not a Windows user (he did not have a Windows script for this) so reckon I might have corrupted it.
I did as you advised and made some real progress. Now we get the following:
[email protected] ~ $ sudo ./extract-files.sh
[sudo] password for megan:
egrep: ../express/proprietary-files.txt: No such file or directory
: not foundefiles.sh: 3: ./setup-makefiles.sh:
: Directory nonexistentk ./setup-makefiles.sh: cannot create ../../../vendor/samsung/express
[email protected] ~ $
It breaks further down the script. In the home folder there is proprietary-files.txt which list the files to be extracted along with their file path. Does that message indicate it is looking for proprietary-files.txt in /home/express?
Setup-makefiles.sh is in the home folder as well and appears to be a Cyanogenmod Project file to create a blob from the the results of extract-files.sh
Bazzan
bazzan said:
Does that message indicate it is looking for proprietary-files.txt in /home/express?
Click to expand...
Click to collapse
Yes, that's it. Check again, seems like something is missing yet.
Thanks again. Got it to work by building the folder structure
/home/vendor/Samsung/express
And then running the files from there
Bazzan

Categories

Resources