Related
i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
bilclintonsdaman said:
i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
Click to expand...
Click to collapse
Just had a look at the busybox source and it says it uses the contents of environment variable ENV as a startup script so you could do
Code:
ENV=/system/sd/.bashrc ash
and it'll read /system/sd/.bashrc for your startup commands. Altrernatively, if you invoke it as a login shell (ash -l), it'll source /etc/profile then .profile from the current directory so if you create /system/sd/.profile to contain alias ls='ls --color=always' then as long as you do this
Code:
cd /system/sd
ash -l
you'll have your alias (I just tried this with JF1.51 and it worked great).
I also saw that it will record command history to the file named in HISTFILE so you may want to make your startup script look like this
Code:
alias ls='ls --color=always'
HISTFILE=/system/sd/.histfile
Also, keep in mind that this isn't bash -- you need to use ash shell scripting semantics.
Sweet! Thanks so much
~/.PROFILE
if you edit (may need to create it first) the .profile file in your home directory you shouldn't have an issue
i have the following in my ~/.profile file:
Code:
alias dir='ls -Alp'
alias cls='clear'
The next time you log in, you'll have your alias's
pre-compiled gnu bash
I can't remember where I found it, however, if you know enough to set it up, I have a pre-compiled gnu bash 3.2 file that allows you to execute something like this:
su -c '/path/to/bash --rcfile /path/to/.bashrc'
in the terminal emulator and you'll execute a bash shell with the .bashrc
I attached the pre-compiled gnu bash 3.2 in a zip file on the post, good luck getting it running! google is your friend!
I also compiled bash 4.0 for myself to use, but its kind of buggy since it was actually one of the first binaries that i've ever compiled on linux but it works! its just really slow >.>
I followed this tutorial to compile it
http://www.kbrandt.com/category/bash
Hi All,
The Ash shell provides a few advantages over the Android default sh shell such as command history and cursor handling at the prompt. There are other benefits, but these are the first that come in most handy (to me).
The following tutorial will get you ash as the login shell with as yet no ill effects:
Note: that in my case, I'm using my android2sd construct and thus this modification is being done to my active overlay profile setup, thus to undo it I can simply boot into "safe\\normal" mode and undo the changes without possibly locking me out of the console should it have failed (which it didn't) But you can edit the Android /system/bin/sh file in this manner directly.
Ash as Login Shell:
OK, make the /system fs read-write:
mount -o remount,rw /system
Click to expand...
Click to collapse
Note: that the fs type is not needed, and in my case is not yaffs but ext3, Android will figure it out proper.
Next,
cp -a /system/bin/sh /system/bin/sh0
Click to expand...
Click to collapse
(this is for backup purposes and allows us to undo the change if so desired, or delete it if no longer needed).
Note: I'm using JF1.51 roms, so busybox ash is available as /system/xbin/bb/ash, so that is what I am using here; use ash however you are able to access it.
echo "#!/system/xbin/bb/ash">/system/bin/sh
echo "/system/xbin/bb/ash \[email protected]">>/system/bin/sh
Click to expand...
Click to collapse
Please note the use of (redirect\\overwrite)> and (redirect\\append)>>.
This will overwrite sh with a script to load the desired shell, executing any command-line arguments passed, and preserve the permissions of the original sh file. You can manually set the permissions the same as they are for our sh0 backup if the permissions (root.shell)(0755) don't seem to keep.
Finally reset the read-only state of /system:
mount -o remount,ro /system
Click to expand...
Click to collapse
Now if you shell-in\\telnet-in you should get the ash prompt which unlike the Android sh default prompt, includes the present working directory(pwd) ie: '/#' instead of just '#'.
Note: A reboot should not cause the loss of the modification, but if does, copy the new sh script to your /data/local/bin location or something and copy it back via boot script or something.
Shell Scripts:
If you're like me, you discovered that Android didn't need the interpreter declaration comment in scripts, and thus may not have used them...Well, you will need to update your scripts to include them by adding something similar to the following as the first line of your scripts:
#!/system/xbin/bb/ash
Click to expand...
Click to collapse
Again, please note that I am using JF1.51 roms and the location of the busybox ash shell is what I'm listing; put the full location to the shell you intend to use as this location.
Without the interpreter declaration, ash simply complains 'not found' at the first command, as ash doesn't know how to interpret the script, and doesn't seem to default to the login shell.
Hope someone finds this helpful!
sweet. This is going to be very useful
BAM. thats sexy. i just did this on CM3.6.7.1. works like a charm.
scratches head. i'm lost. what does this do and how does this make my g1 better?
temporizer said:
scratches head. i'm lost. what does this do and how does this make my g1 better?
Click to expand...
Click to collapse
im not sure about the other features, but the one i installed it for is to have your working directory in front of ur prompt. ex:
Code:
/# cd /sdcard
/sdcard # cd /system/sd
/system/sd #
etc...
EDIT: Also, if you use ConnectBot, you'll notice with the regular sh, if u scroll up with tracball, you get BS characters on the prompt. with THIS one, when you scroll up, you get last command entered. VERY handy for when you mistype one character on a long-ass command.
I love you
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
great job, i'm going to get ash working on my G1 (CM-3.6.7.1)
Thanks.
kanstin said:
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
Click to expand...
Click to collapse
I tried this and it worked even after a reboot...
Sweet, I love the scroll back with trackball in the terminal!!! Me thinks this should get absorbed into the next Cyan release.
kanstin said:
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
Click to expand...
Click to collapse
Yes, I reckon you could. Though I had done a few experiments where the symlink failed, but I'm fairly sure it was do to the link: /system/xbin/bb/ash -->../busybox and /system/bin/../busybox not existing...so I did it via script. Many ways to skin a cat they say.
Thank you all... this is fricken awesome!!
temporizer said:
scratches head. i'm lost. what does this do and how does this make my g1 better?
Click to expand...
Click to collapse
It gives a more advanced shell for when you use the command line interface or telnet into your G1. If you don't use the command line a lot, it won't help you.
As for specific benefits to the advanced version, it was listed in the first post.
Hi,
imho this is rather a hack that exposes you to the risk at least on CM to loose your
shell during boot as xbin.sqf the compressed squashfs filesystem containing
busybox is mounted rather late in the boot process. A cleaner solution would be to
move busybox to system/bin and link it to sh. That way you ensure that sh will
always be accessible during boot and also later on, thus not interfering with
further developments. A alternative could be to compile a standalone version
of busybox containing only ash (for size reasons, as size in /system/bin is precious)
copy that to /system/bin and link sh to it.
Seems to work fine on Dude's. Not really sure how it should open, but I type "ash" at the prompt and I get the /$ and /# if superuser. I also get the command history by rolling the trackball, which is a very nice feature.
Can i install this without using my PC?
temporizer said:
Can i install this without using my PC?
Click to expand...
Click to collapse
Should work using terminal.
Tried it on JACHero 2.7.1
I tried the hard link one and I get a read only fs error on the first move command. What should I chmod to get past that?
mugafuga said:
I tried the hard link one and I get a read only fs error on the first move command. What should I chmod to get past that?
Click to expand...
Click to collapse
Do this first before the mv and the symlink.
mount -o remount,rw /system
farmatito said:
Hi,
imho this is rather a hack that exposes you to the risk at least on CM to loose your
shell during boot as xbin.sqf the compressed squashfs filesystem containing
busybox is mounted rather late in the boot process. A cleaner solution would be to
move busybox to system/bin and link it to sh. That way you ensure that sh will
always be accessible during boot and also later on, thus not interfering with
further developments. A alternative could be to compile a standalone version
of busybox containing only ash (for size reasons, as size in /system/bin is precious)
copy that to /system/bin and link sh to it.
Click to expand...
Click to collapse
Is this in any way accurate? I dedicate my g1 to cyan's roms and wouldn't want anything to hinder any of the goodness that is cyanogenMod. Advice?
Load ash when terminal is started?
temporizer said:
Is this in any way accurate? I dedicate my g1 to cyan's roms and wouldn't want anything to hinder any of the goodness that is cyanogenMod. Advice?
Click to expand...
Click to collapse
Safest method will be to change to ash shell once terminal app is started (same as typing "ash" to switch shell from sh to ash). I don't know how to do it in android (in linux you could add it to your login script).
So if someone knows how to execute a command when we login using the terminal app, then switching to ash shell would work without fear of breaking any other functionality.
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
i think that if you do:
su (to get superuser privileges)
sh your_script.sh
might work....
alternative is to install gscript and put your script in the gscript folder on sdcard....
The console needs to be granted superuser access, then ran as sh script.sh or bash script.sh. afaik at least. Youll probably have to use su like the person above said.
I did the su command. But i still can't open it. All other commands work.
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
ryocoon said:
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
Click to expand...
Click to collapse
This should be the solution. X is the execute bit. Basically without that bit set on the file permissions, the OS won't allow that file to be executed as a program.
chmod +x filename.sh
Try running that command in terminal emulator and it should clear things up.
Sent from my Inspire 4G using XDA App
I used that command and it said 'bad mode'.
It still doesn't work.
If you are running the script with this:
Code:
sh script.sh
then the executable bit doesn't need to be set in order to execute it, since you are specifying 'sh'. If you were trying to run it with this:
Code:
./script.sh
then it would require the executable bit to be set.
In an attempt to answer the question, where abouts is your script saved and which user owns it? Just as a quick test on mine, I made a script named test.sh (containing the same lines as yours) on the root of my sd card, cd'd to it and ran sh test.sh, and that seemed to work. That script ended up being owned by 'system'.
As a test to make sure sh is behaving, can you run the following from the terminal:
Code:
sh -c 'echo hello'
EDIT: note that all of the above was run as a regular user, not root.
Yeh it said hello when i did the command you said.
It must be a problem with the file in some way then. Can you run the following from the folder that your script is in and give the output?
Code:
ls -l | grep script.sh
Also, what did you use to make the script - terminal in Android, or adb'd it from your PC etc?
(Aside: just a thought, you probably can't do chmod's on sdcard files if it's formatted to FAT32 since FAT32 doesn't understand Linux permissions)
you can also try an app i found some time ago. SL4A
I made the file with silveredit. Just renamed .txt to .sh.
Btw i got it working with gscript, thanks for everyone's help
Run a reverse tethering shell script
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
nok2626 said:
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
Click to expand...
Click to collapse
it's because android doesn't know about these command, this is a native linux command, try to install busybox, edit your script like this
Code:
busybox ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
busybox route add default gw 192.168.137.1 dev usb0
busybox setprop net.dns1 8.8.8.8
busybox setprop "net.grps.http-proxy" ""
I hope these helpfull
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
Even though your device is rooted, android environment won't allow applications to execute 'sh' commands.
As android security architecture says, applications run within a secured execution space inside Application Sandbox, sh execution can bypass this security.
If there are any exceptional cases where few devices allow 'sh' execution, well... OEM's needs to be reviewed again.
Answer
Maybe you can try the method that I have specified and check whether it works
http://forum.xda-developers.com/showthread.php?t=2620394
krutle said:
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
Click to expand...
Click to collapse
the script is already run and no need to type the command again, note: some script files can damage your system if run twice
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
You have to put the script somewhere that it has permission to execute from, copy it to /data/local/tmp first. Then in your terminal run each of these commands;
su
cd /data/local/tmp/
chmod 0755 MyScriptName.sh
./MyScriptName.sh
As a new Android user but experienced in Linux I wanted to explore the command shell. I've wanted to change passwords and have use the usual commands I would normally expect to be available.
I'd like to share my experience for any other new user and open the discussion for for additions and corrections. What I say here works on a Galaxy Mini S5570 but should be pretty generic. This really does need the phone to be rooted or much will be inaccessible.
Comparing 3 methods Terminal Emulator, DigiSSHD which is run from DigiControl and SSHDroid.
There is no concept of a root password as access is granted via superuser app. When you connect your id is set from the id of the app you are using to connect.
The simplest connection is via Terminal Emulator. It requires no network connection and gives direct access to the phone. The first thing is that you have no home directory so you are dumped into / the top directory. There is no .bash_profile, .bashrc or .profile so it's customisation is not obvious.
I tested SSHDroid and DigiSSHD using wi-fi. My ssh client was the excellent Putty on Windows7.
As default SSHDroid uses port 22 while DigiSSHD uses port 2222.
For a rooted phone SSHDroid has user "root" with password "admin". This is not your device's root password. You can think of it as an access password for SSHDroid. This access password can be changed in the options for SSHDroid. It is a good idea to do so stop others getting in just as you have done.
You arrive in a home directory data/data/berserker.android.apps.sshdroid/home and inside there you will find a .profile file so you can do some customisations there. The good news is that all the usual linux functions are available in ~/bin via the PATH variable it gives you and its own busybox.
Neither Terminal Emulator nor DigiSSHD give you these functions but this is a good way to do it.
Terminal Emulator by default gives you a PATH which includes /data/local/bin. This is set by Initial Command in the Preferences but I'm taking it as it is.
There was no directory /data/local/bin. This is good because we can create it and put our own stuff in there wihout having inconsistent clashes. Create it with the correct permissions. Copy the permissions of another directory in the path in my case I used /system/bin. To check the permissions:
cd /system
ls -l
The permissions were for bin are drwxr-xr-x with Owner/Group of root and Shell. So create the new directory.
cd /data/local
mkdir bin
chmod 755 bin
chown root.Shell bin
Now you can start creating your utilities. Before you do check that each is not already available by trying to run it. It might already be provided by Toolbox. To see what busybox can do type
busybox --help
To get your utility, assuming it is available in busybox create a symlink to busybox with the name of the utility. As an example this is how to create 'more' and 'less' and the standard 'vi'
cd /data/local/bin
ln -s /system/xbin/busybox more
ln -s /system/xbin/busybox/less
ln -s /system/xbin/busybox/vi
You can carry on activating your favourite utilities. Remember to check if it already there first and NEVER forget you are doing all this as root so take care...
Why do it this way and not use the functions provided by SSHDroid? Well as an ordinary user you may not have access and if you decide to uninstall SSHDroid you would probably lose it.
Now for DigiSSHD. The default user is android with a password of 123. I have not found how to change this yet so comments welcome. Your home directory will be something like /mnt/sdcard/Android/data/org.digimead.digi.ctrl/files/var/1d7a337e-7cf8-4b28-8039-baa894f7185f
There is a .profile file in your home directory that you can edit and add the line
export PATH=/data/local/bin:$PATH
This will give you access to the same utilities (so same versions) as you have with Terminal Emulator.
That's it. The rest is up to you. Which utilities you chose and which command line app suits you. I doubt that all the busybox functions will work on an Android system because it is not an ordinary Linux.
Which is better, SSHDroid or DigiSSHD? I don't know. I'll leave that for others to comment.
Are you the admin on this other site? Terminal and SSH Access Just curious as this is exact copy/paste post from that post with no links or attributions.
Flashize: Turn Shell Scripts Into Flashable Recovery Zips
Highlights
Automatically convert shell scripts to flashable zips with a single command.
Don't mess with 'ui_print' crap: standard output and error streams will work just fine.
Can be configured to create a logfile of the execution of the script.
Free software: uses GPL and LGPL version 3 and later licenses.
This is a discussion thread. New versions will not be announced here.
Please 'watch' the Github project to receive notifications. Thank you!
More Info -> HERE
Downloads -> HERE
XDA:DevDB Information
flashize, Tool/Utility for all devices (see above for details)
Contributors
Lanchon
Version Information
Status: Testing
Created 2016-02-12
Last Updated 2016-03-19
Flashize
Downloads -> HERE
Reserved
Wow this is awesome Lanchon!
Sent from my Nexus 6P using Tapatalk
This is so awesome! Thank you!
Lanchon said:
Flashize: Turn Shell Scripts Into Flashable Recovery Zips
Features
Automatically convert shell scripts to flashable zips with a single command.
Don't mess with 'ui_print' crap: standard output and error streams will work just fine.
Displays the script exit code and reports it back to recovery.
The script receives the full path of the zip being flashed as its first parameter.
(Other parameters reserved for future use.)
Free software: uses GPL and LGPL version 3 and later licenses.
For Linux and Un*x-like systems only: requires 'Bash' shell.
(It would be very easy to port to Windoze proprietary crapware, but I won't do it.)
Usage
flashize <input-script> [<output-zip>]
XDA:DevDB Information
flashize, Tool/Utility for all devices (see above for details)
Contributors
Lanchon
Version Information
Status: Testing
Created 2016-02-12
Last Updated 2016-02-12
Click to expand...
Click to collapse
thanks bro brilliant idea works perfect going to share on my Google +
I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?
misterpyrrhuloxia said:
I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?
Click to expand...
Click to collapse
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
you might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and Linux.
bigsupersquid said:
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
you might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and Linux.
Click to expand...
Click to collapse
I don't know what rootfs is... And is that the exact command I should run on my phone?
misterpyrrhuloxia said:
I don't know what rootfs is... And is that the exact command I should run on my phone?
Click to expand...
Click to collapse
exact
Code:
su
mount -o remount,rw / /
Please help us Windows guys with this. I have a bricked g stylo.This sounds like it could be my salvation!! Thanks either way.
Sent from my N9521 using Tapatalk
bigsupersquid said:
exact
Code:
su
mount -o remount,rw / /
Click to expand...
Click to collapse
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.
misterpyrrhuloxia said:
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.
Click to expand...
Click to collapse
are you running stock rom? older cm?
it can't find the zip utility. there may not be one.
newer cm can unzip and zip in terminal.
regardless, the android command line environment you're working with might not be complete enough for the script to work.
misterpyrrhuloxia said:
I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?
Click to expand...
Click to collapse
the script doesnt work because its a BASH script. bash is the most common shell in linux. stupid google doesnt want GPL code in userland android so it cant be part of android, just like busybox cant.
it doesnt start because the first line "#!/bin/bash" tells the kernel that bash should be used to open it, and obviously bash is not found in /bin/bash in your phone.
you dont need to rename or chmod the script, you can just invoke it with "sh <name>". but then ASH, a different shell part of busybox, is running it. it was not designed to be run with ash, so no idea whether it should work.
DO NOT mount your system RW and run inappropriate scripts!!!! you can kill you OS!
ill take a look sometime and see if it can be hosted in android.
but first, one question: what is the use case? no use case, no code
bigsupersquid said:
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
You might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and linux.
Click to expand...
Click to collapse
do not do this!
misterpyrrhuloxia said:
I don't know what rootfs is... And is that the exact command I should run on my phone?
Click to expand...
Click to collapse
in my script change the line:
td="/tmp/lanchon-flashize"
to some writeable folder you want to use, such as:
td="/sdcard/lanchon-flashize"
misterpyrrhuloxia said:
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.
Click to expand...
Click to collapse
and now you need to have the 'zip' binary installed. CM11 has it. dont ask me how to get one!
Lanchon said:
do not do this!
Click to expand...
Click to collapse
I've not had issues myself with overwriting the initrd files even since they reset to the stored boot.img versions on reboot.
but creating things in / would use ram at the least, and I imagine there's devices with overwriteable rootfs, so I definitely understand your warning.
apologies, didn't mean to hijack.
bigsupersquid said:
I've not had issues myself with overwriting the initrd files even since they reset to the stored boot.img versions on reboot.
but creating things in / would use ram at the least, and I imagine there's devices with overwriteable rootfs, so I definitely understand your warning.
apologies, didn't mean to hijack.
Click to expand...
Click to collapse
no prob, its just dangerous
Lanchon said:
in my script change the line:
td="/tmp/lanchon-flashize"
to some writeable folder you want to use, such as:
td="/sdcard/lanchon-flashize"
Click to expand...
Click to collapse
Lanchon said:
and now you need to have the 'zip' binary installed. CM11 has it. dont ask me how to get one!
Click to expand...
Click to collapse
So I got it working in Android!! First of all, I had to change in the script the line
Code:
td="/tmp/lanchon-flashize"
to
Code:
td="/sdcard/lanchon-flashize"
Then I installed a zip utility for Android that I downloaded from here. Then I decided that I wanted a flashable zip. So attached below is a flashable zip that does these things:
Places your Flashize script in /data/local/Flashize.
Installs the Android Zip utility to be able to zip files in the terminal (like unto the utility in CM that you mentioned above).
Creates a command line alias in /system/etc/mkshrc so that way all you have to do to execute the Flashize script is type the command "flashize" in the terminal. This is the same type of aliasing that's common in Linux systems with the ~/.bashrc file.
So after flashing this, all you have to do on your phone to create a flashable zip with Flashize is to navigate to the directory where your shell script is, and run the same command as what's in the OP:
Code:
su
flashize <input-script> [<output-zip>]
What do you think, @Lanchon?
If this helped you out, hit thanks!
This has only been tested on the Motorola Nexus 6 running Pure Nexus rom.