[DEAD] Bash Shell Scripting - Android

( Project repo has been deleted )

Have you seen Bash Guide for Beginners and Advanced Bash-Scripting Guide from tldp.org (google, I cannot post links yet)? I think they are excellent.

Cheers
Thanks mate for that !

How to get the tutorials:
Code:
git clone https://github.com/d0wngrade/d0.git
(This will download my entire 'd0' github repo, it's pretty empty right now.)
The tutorials are under the d0/Papers/xda_Bash/ directory.
Click to expand...
Click to collapse
Hi Where to type that code to download tutorials?
is it in android shell?
---------- Post added at 03:20 PM ---------- Previous post was at 03:15 PM ----------
SOLVED.
Just pasted it in internet browser

Should have just copy/pasted the tutorials on the thread. A little misleading if you ask me...

Hi, I wrote a simple .sh file to batch install apps from sdcard.
What I did was I copied the same terminal commands to a inst.sh file and tried to execute the script from shell
using following commands
SU
sh /sdcard/inst.sh
Following is the code of my .sh file
pm install "sdcard/apps/Google_Maps_6_14_4.apk"
pm install "sdcard/apps/Quick Boot.apk"
Then I get an error "Failure [INSTALL_FAILED_INVALID_URI]"
I can run the command pm install "sdcard/apps/Quick Boot.apk" in terminal individually in terminal.

rsd3k said:
Hi, I wrote a simple .sh file to batch install apps from sdcard.
What I did was I copied the same terminal commands to a inst.sh file and tried to execute the script from shell
using following commands
SU
sh /sdcard/inst.sh
Following is the code of my .sh file
pm install "sdcard/apps/Google_Maps_6_14_4.apk"
pm install "sdcard/apps/Quick Boot.apk"
Then I get an error "Failure [INSTALL_FAILED_INVALID_URI]"
I can run the command pm install "sdcard/apps/Quick Boot.apk" in terminal individually in terminal.
Click to expand...
Click to collapse
Wow, I hate to resurrect a year old thread but this literally my EXACT problem (and the first post I've seen referencing my specific circumstance). I too can use the pm install command just find from the terminal emulator, but the minute I try to execute it from a script, I get the infamous INVALID_URI failure. No one has any idea what this could be?

Hey, try putting a forward slash before "sdcard".
Sent from my XT1080 using XDA Free mobile app

d0wngrade said:
I haven't seen any tutorials covering bash in detail, so I'd like to post a project I'm working on to help people learn bash...
Tutorial One:
Covers basic math
Covers basic if..else..fi
Covers calling external scripts
How to get the tutorials:
Code:
git clone https://github.com/d0wngrade/d0.git
(This will download my entire 'd0' github repo, it's pretty empty right now.)
The tutorials are under the d0/Papers/xda_Bash/ directory.
More tutorials will be added when I get time to do them, I only intend to do this in my spare time. Thank you!
Click to expand...
Click to collapse
Thanks mate for that !

I was looking for a Tutorial specific to scripting on android but it looks like maybe this on is dead...
Correct me if im wrong..

nutpants said:
I was looking for a Tutorial specific to scripting on android but it looks like maybe this on is dead...
Correct me if im wrong..
Click to expand...
Click to collapse
Yes, this project is dead. I removed the GitHub repo too, so...
Anyways what did you meaning by "scripting on Android"?

Writing and running bash ( or other) script files on android devices.
Just trying to keep my Brain active with limited internet access.

Related

[Q] [ Backtrack 5 on LGP500 ]

Ive seen that the Backtrack 5 can be installed on xperia x10..
here's the link
Does it work on LGP500 too?
It would be great if this would work on our phone to give some special features..
up please answer my question.
rexon2011 said:
up please answer my question.
Click to expand...
Click to collapse
Hmmm? Well, go and try it?
I tried... at first i thought it should work. As the file system and all are similar
It worked till the 'startbt' but when i entered 'bt' it said segmentation fault
So anyone can tell me please what i have done wrong ( I know the wrong thing is its not meant for Optimus but anything other than that?? ) or tell me how to make it work
Thank you
PS --> My First post on XDA
Ohk looks like something is missing.
do following
reboot your phone do startbt as usual...
after that us
http://forum.xda-developers.com/showpost.php?p=14006091&postcount=15
this script copy script to any location and run it.
sh debug.sh
output will be in /data/local/debug_log.txt
just copy paste the whole file here.
tips you can push the debug.sh file using adb push.
and simmilarly pull the log out using adb pull.
once you are done then post the debug log that can help in diagnostics.
anantshri said:
Ohk looks like something is missing.
do following
reboot your phone do startbt as usual...
after that us
http://forum.xda-developers.com/showpost.php?p=14006091&postcount=15
this script copy script to any location and run it.
sh debug.sh
output will be in /data/local/debug_log.txt
just copy paste the whole file here.
tips you can push the debug.sh file using adb push.
and simmilarly pull the log out using adb pull.
once you are done then post the debug log that can help in diagnostics.
Click to expand...
Click to collapse
http://www.mediafire.com/?x4kuvorawo4reqr
is this the debug log u wer asking??
please do something... i am too much exited to try it on my optimus
BTW add me on FB i have sent u a friend request
cooltoad92 said:
http://www.mediafire.com/?x4kuvorawo4reqr
is this the debug log u wer asking??
please do something... i am too much exited to try it on my optimus
BTW add me on FB i have sent u a friend request
Click to expand...
Click to collapse
two things.
1) reboot your phone and do startbt and bt again.
post all output here.
2) also segmentation fault could be coz of the busybox chrooting failure.
i hve busybox version 1.15.3
anantshri said:
Ohk looks like something is missing.
do following
reboot your phone do startbt as usual...
after that us
http://forum.xda-developers.com/showpost.php?p=14006091&postcount=15
this script copy script to any location and run it.
sh debug.sh
output will be in /data/local/debug_log.txt
just copy paste the whole file here.
tips you can push the debug.sh file using adb push.
and simmilarly pull the log out using adb pull.
once you are done then post the debug log that can help in diagnostics.
Click to expand...
Click to collapse
When i try to run BackTrack 5 on my P500 Optimus One with Gingerbread 2.3 and root installed, i get this error:
mkdir failed for data/local/mnt, File exists
net.ipv4.ip_forward = 1
Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:
eth0: No such device
Segmentation fault
Shutting down BackTrack ARM
losetup: /dev/loop7: Device or resource busy
Here mine debug.sh.txt: http://www.megaupload.com/?d=2SE35OPZ
Can anyone help me?
You really need a bigger screen size to get this working properly.

[Q] Anyone get Ubuntu working...?

hi guys, i have an optimus v just lying around, and today i decided to try and get ubuntu on it through chroot.
using this guide, i was able to get to the point where it would boot on the command line,
Code:
[email protected]:/#
instead of the normal "#"
but after that, i tried to get it to work in a GUI, but it doesn't work?
i tried
Code:
apt-get update
and it runs, but gives me a bunch of fails and errors...
so of course, without that installed, i can't get any of the servers or other stuff installed, meaning that i can't get the GUI working...
so did anyone get this to work?
(i'm starting to think that it's their problem...)
thanks guys
i'll try to get a photo to show...
OK... First picture shows it booting into Ubuntu
Second picture shows the fail when I try the apt-get update command
Sent from my HTC Glacier Sense 3.5 using xda premium
the error messages says all: you have a network problem, may be no wifi connection or working dns?
andy572 said:
the error messages says all: you have a network problem, may be no wifi connection or working dns?
Click to expand...
Click to collapse
hm that's weird... i have a wifi connection... i tried it on two devices and both could boot up linux, just not get the downloads?
hmmmmm...
what version of ubuntu? nvm, I see your screenshot says karmic, which should work.
more recent versions don't support armv6, so apt-get fails to download any unsupported package.
there's a thread in the optimus v dev section on installing debian.
squeeze and even sid run great on the OV for a 600MHz device with a tiny screen and no keyboard
try checking your /etc/apt/sources.list and make sure it's correct. It looks wrong to me, but I only use ubuntu for my DTV usb stick on my pc. I'm more a debian user myself.
edit again:
you can manually download .deb files and install them from the chroot command line with
dpkg -i filename.deb
just make sure they're for armel architecture; however, with ubuntu being too picky about the processor type, not all armel ubuntu packages will work. If you search google for ubuntu karmic armel whateverthehey.deb you should get stuff that will work. The main problem with manual installs is getting all the dependency .deb's, apt-get is really handy for that step.
---------- Post added at 01:59 PM ---------- Previous post was at 01:29 PM ----------
ok, that sources.list entry in the screenshot looks REALLY wrong.
there is a stock version of the sources.list contents posted here
try putting that in there and maybe apt-get will work.
bigsupersquid said:
what version of ubuntu? nvm, I see your screenshot says karmic, which should work.
more recent versions don't support armv6, so apt-get fails to download any unsupported package.
there's a thread in the optimus v dev section on installing debian.
squeeze and even sid run great on the OV for a 600MHz device with a tiny screen and no keyboard
try checking your /etc/apt/sources.list and make sure it's correct. It looks wrong to me, but I only use ubuntu for my DTV usb stick on my pc. I'm more a debian user myself.
edit again:
you can manually download .deb files and install them from the chroot command line with
dpkg -i filename.deb
just make sure they're for armel architecture; however, with ubuntu being too picky about the processor type, not all armel ubuntu packages will work. If you search google for ubuntu karmic armel whateverthehey.deb you should get stuff that will work. The main problem with manual installs is getting all the dependency .deb's, apt-get is really handy for that step.
---------- Post added at 01:59 PM ---------- Previous post was at 01:29 PM ----------
ok, that sources.list entry in the screenshot looks REALLY wrong.
there is a stock version of the sources.list contents posted here
try putting that in there and maybe apt-get will work.
Click to expand...
Click to collapse
alright thanks... not sure if i get you completely...
i tried it on my actual phone (Mytouch 4G) and on a dell streak 7, both ARM7 CPUs and no luck on neither. i even turned off wifi on my MT4G and tried to download the packages through my mobile data, still no work...
so how would i go about getting the sources list on there..?
and where can i find the .deb files to install then manually?
thankss
go to the link I posted that says "here" and copy/paste the contents of that post into a plain text file named "sources.list"
put it in your ubuntu image (or partition, whatever it is) in /etc/apt/
as far as where to get .debs, google for what program you want to install, make sure to include "ubuntu karmic armel" in the search.
since you're using armv7, you can upgrade the ubuntu release without problems for those devices, the OV will have to stay with karmic I think.
your issue right now is that apt is trying to download from somewhere other than the default repositories, and it can't find where it's looking for.
bigsupersquid said:
go to the link I posted that says "here" and copy/paste the contents of that post into a plain text file named "sources.list"
put it in your ubuntu image (or partition, whatever it is) in /etc/apt/
as far as where to get .debs, google for what program you want to install, make sure to include "ubuntu karmic armel" in the search.
since you're using armv7, you can upgrade the ubuntu release without problems for those devices, the OV will have to stay with karmic I think.
your issue right now is that apt is trying to download from somewhere other than the default repositories, and it can't find where it's looking for.
Click to expand...
Click to collapse
hm... ok... so here's the contents of the .zip i downloaded to get ubuntu running from here
where do i put it..?
you'll have to mount ubuntu.img as a loop device and put it in that directory's etc/apt/ folder.
probably can copy it in once running on-device, you'll have to figure out where in your filesysyem the img is mounted.
i'm not familiar with the method you're using so I can't be more specific, sorry.
alright guys FINALLY GOT IT!!
you have to replace the original server in
Code:
data/local/ubuntu/etc/apt/sources.list
with this:
Code:
http://old-releases.ubuntu.com/ubuntu/
and then it should work!
saranhai said:
alright guys FINALLY GOT IT!!
you have to replace the original server in
Code:
data/local/ubuntu/etc/apt/sources.list
with this:
Code:
http://old-releases.ubuntu.com/ubuntu/
and then it should work!
Click to expand...
Click to collapse
Here's proof
Sent from my HTC Glacier Sense 3.5 using xda premium

[TOOL] Clean Tool for Mac OSX

All credits go to Scrosler, Nils, MrSmith, and everyone else. I took the Linux version of this tool and modified it to work on Mac OSX. The Linux version did not work for me, so I decided to fix up a Mac version and upload. It also has a special WiFi Tether install script I whipped up.
INSTALL THE MAC OSX ANDROID SDK BEFORE USING THIS!
Here are some links to get you started with the SDK.
http://developer.android.com/sdk/index.html
http://www.talkandroid.com/guides/de.../#.TuaS3lxjgSM
So now that you have the SDK installed...
1) Unzip Cleantool_Mac.zip
2) Open a command window, change directory into your Cleantool_Mac directory
3) Run ./cleantool.sh
Have fun
Cool! Good Job!
What exactly does this remove?
McFroger3 said:
What exactly does this remove?
Click to expand...
Click to collapse
Well, you can Temp Root, and then you are given the option to remove some bloat, all bloat, or VZW bloat, and you can also desense
dmeadows013 said:
http://www.talkandroid.com/guides/de.../#.TuaS3lxjgSM
Click to expand...
Click to collapse
Just to let you know this link redirects to
http://www.talkandroid.com/73163-dead-on-arrival-makes-its-way-to-the-android-market/#.TuaS3lxjgSM
McFroger3 said:
Just to let you know this link redirects to
http://www.talkandroid.com/73163-dead-on-arrival-makes-its-way-to-the-android-market/#.TuaS3lxjgSM
Click to expand...
Click to collapse
The link you quoted and in the OP goes to guides as I would assume were intended. Don't know how/why you would get to somewhere completely different.
MrSmith317 said:
The link you quoted and in the OP goes to guides as I would assume were intended. Don't know how/why you would get to somewhere completely different.
Click to expand...
Click to collapse
Worked fine for me too!
cant seem to get the command screen to accept my commands. Pretty much a nube when it comes to command screens and code, but if anyone could help lead me in the right direction, i'd appreciate it. I already have sdk installed and the cleantool zip unzipped. Just not sure where to go from here, as everything i've tried on the command screen has come back permission denied, or no such directory. Thanks in advance...
In terminal I get to a Password prompt?
Edit: Nevermind, just hit Enter. Doh!
---------- Post added at 03:04 PM ---------- Previous post was at 02:55 PM ----------
Do you have it for permanent root?
---------- Post added at 03:14 PM ---------- Previous post was at 03:04 PM ----------
How do we get permanent root on a mac?
Sorry, I just saw I somehow wrote that on my post above.
---------- Post added at 03:22 PM ---------- Previous post was at 03:14 PM ----------
jdaniels31 said:
cant seem to get the command screen to accept my commands. Pretty much a nube when it comes to command screens and code, but if anyone could help lead me in the right direction, i'd appreciate it. I already have sdk installed and the cleantool zip unzipped. Just not sure where to go from here, as everything i've tried on the command screen has come back permission denied, or no such directory. Thanks in advance...
Click to expand...
Click to collapse
1. In the Terminal app ( /Applications/Utilities )
type: cd (path to Cleantool_Mac folder - Easiest way to do this is to open a Finder window next to the Terminal window, navigate to the Clean folder in the Finder window and then drag the folder into the Terminal window. Make sure it has a space between the cd and the path.)
Example: cd /Users/username/Desktop/Clean_Mac
Hit Return or Enter
2. At the next prompt: Type: ./cleantool.sh
3. Select the Temp Root option then let it do it's thang and then select the Exit option.
Hope that helps.

How to auto-execute our own script?

Ok, so I have been using linux since long and I managed to write many scripts for my personal management, using crontabs for auto-execute etc. I also played with rc.local in linux. Fortunately It was all easy to find the relevant info whenever I want. But not with Android. I have been searching but no exact solution so far.
I want to know how to auto-execute script on start up? I have put script in /system/etc/init.d changed its permission to 755. Made chown to root, but Fail.
Also tried to use "Script Manager" but that force closes everytime. I switched to Cm7.2 Sedan yesterday and same case with this ROM too. (So I don't think Its a ROM related). This the same ROM Turbo-boost or other scripts works fine.. What is it that I'm missing here?
Afaik userinit script at /data/local/userinit.d
Rushyang said:
What is it that I'm missing here?
Click to expand...
Click to collapse
Since you're saying that other scripts get properly executed, than it must be your custom script itself, which poses some problems here? Btw, nobody is right in your head or is a visionary and able to give you some help, if you don't give some bits of code to tell, what might be basically wrong with it. ...
Just jump over to slaid's scripting threads. There are some hints and tips how to log and debug initd scripts. Or you can just strip from g_BonE's script the debugging code and apply it to your own script.
Happy scripting! ...
[xXx]
---------- Post added at 08:21 PM ---------- Previous post was at 08:15 PM ----------
As a matter of fact, iandol was so kind enough and did already strip the necessary code for you. ...
[xXx]

Revone 0.2 failing to map memory with no error code

For the last two days I have been trying this Ive been getting this error... EVERYTIME! I cant see that I am doing anything wrong in cmd. No clue what to do.
No luck with moonshine either
Also, installed Ubuntu, ran distiller... Nothing. It tells me to "run distiller again and READ" BTW, all radios were off when this happened
I'm not an expert by any means. But when you downloaded adb, did you download the sdk for android? If so, go to sdk manager and make sure you have all the options under tools installed. Secondly, did you rename it to revone.2.0? I used revone.DNA, and while it took me 24+ hours, and 100s of tries, I finally got it to go through. Just to confirm, so far you have pushed adb revone to the device via the adb push revone.2.0 /data/local/tmp, then adb shell, cd /data/local/tmp, chmod 755 revone.2.0? I have found that some people have gotten success from removing -P from the command.
---------- Post added at 06:42 AM ---------- Previous post was at 06:38 AM ----------
It may work easier if you move adb to a folder in C: and title the folder something like adb_android, and move the revone file in there as well. From there, you can go to the search bar, enter cmd.exe and it will bring you in directly at C:\ adb_android.
Why don't you post this as a reply to the revone thread? We don't need a new thread every single time someone runs into an issue s-offing their phone...
So Im not entirely sure how to open the sdk manager. I unzipped the adb folder (it was the ADT package), renamed it DNA and placed it under my C:\ drive. Also, I had downloaded the updated revone (revone-0.2) and just removed the dash and have tried removing and adding the -P with identical results.. I have also done many factory resets and still the same problem. From what it seems like, my problem would be with the sdk manager?
shobon said:
Why don't you post this as a reply to the revone thread? We don't need a new thread every single time someone runs into an issue s-offing their phone...
Click to expand...
Click to collapse
Im a new member and I'm not allowed to post in that section. Ive gone through darn near every page of that thread and it seems my problem was unique. Sorry for flooding the forum, I was just looking for some help.
jenniferstough said:
I'm not an expert by any means. But when you downloaded adb, did you download the sdk for android? If so, go to sdk manager and make sure you have all the options under tools installed. Secondly, did you rename it to revone.2.0? I used revone.DNA, and while it took me 24+ hours, and 100s of tries, I finally got it to go through. Just to confirm, so far you have pushed adb revone to the device via the adb push revone.2.0 /data/local/tmp, then adb shell, cd /data/local/tmp, chmod 755 revone.2.0? I have found that some people have gotten success from removing -P from the command.
---------- Post added at 06:42 AM ---------- Previous post was at 06:38 AM ----------
It may work easier if you move adb to a folder in C: and title the folder something like adb_android, and move the revone file in there as well. From there, you can go to the search bar, enter cmd.exe and it will bring you in directly at C:\ adb_android.
Click to expand...
Click to collapse
I installed java and got the sdk manager working, everything is installed and I still cant get it to work. ugh
SpacemanJake said:
I installed java and got the sdk manager working, everything is installed and I still cant get it to work. ugh
Click to expand...
Click to collapse
Tbh it took about my tenth time. I don't know why but if you don't want to switch to linux just keep trying
Sent from my HTC6435LVW using Tapatalk 2
SpacemanJake said:
For the last two days I have been trying this Ive been getting this error... EVERYTIME! I cant see that I am doing anything wrong in cmd. No clue what to do.
Click to expand...
Click to collapse
they released an updated zip... maybe try that. mine worked first time this morning no problems
i also cannot post a reply in the regular revone section.
when i download revone-0.2.1 it is not a .zip file...its just a file that cmd wont recognize when i try to push it to the device, it says its not a recognizable file. when i download revone, do i need to move the file to the same directory as adb and fastboot or what?
yes it needs to be in same folder as adb and fastboot
munchy_cool said:
yes it needs to be in same folder as adb and fastboot
Click to expand...
Click to collapse
do i need to change it to a .exe or anything?
nopes...
one last question (which probably should've been my first)...does the DNA already have to be unlocked and/or rooted to use revone? i thought i read that it needed to have an unlocked bootloader to use this.
Got it! Although revone did not work for me at all! I tried to install ubuntu but failed due to windows 8 issue. Downloaded MintLinux 64 bit, used LinuxLive USB Creator to put my .iso on thumb drive, and boot with usb hard disk. In Mint download the 32-bit libraries, download moonshine and run. Done! No adb needed in mintlinux, reboot pc without usb drive if you didnt want to install mint. worked flawlessly.

Categories

Resources