Need to Single-Click a sh script - General Topics

I've got a sh script that when I run it kills the mediaserver process and saves lots of battery. But right now to run it I have to start Sh Script Runner, load the script, execute it, exit script runner
Can someone please show me a way to single-click from my desktop to run this script? I'm running CM7.
Thanks!

Related

Newbie Question about simple script

Hi guys, I was hoping someone could help me write a simple script that I can execute in terminal. What I would like the script to do is copy all the files from one directory to another directory on my sdcard (to cut down what i need to type in terminal each time).
For example
cp /sdcard/dir1/*.* /sdcard/dir2
I've tried to just put that command line in a unix txt file from Crimson Editor, saved it as copy.sh. I did
chmod +x copy.sh
Then tried to type in terminal
sh /sdcard/copy.sh
I didnt get any errors, but I don't think it worked. Any help or suggestions are appreciated.
My phone is a N1 with the latest Cyanogen build. Thanks in advance.
** EDIT **
I fixed the issue by using a program called GScript from the market... I made a new script in the GScript window and can now just open gscript and click the script to run it instead of typing the terminal commands. Don't know if this will help anybody else with similar newbie scripting issues, but it worked for what I wanted to get done. I'm editing post instead of deleting because I don't see the delete post button.
** EDIT **

Set bash as default shell

For a long time I have been running bash on my phone. However at some point you get tired of having to manually enter bash all the time from ssh, adb etc. Therefore I transferred my boot.img to my computer, changed the "console" line in init.rc to point at bash instead of sh and flashed it back to my phone. To my surprise this did not help. Neither adb nor ssh switched to bash by making this change.
I then created a symlink from bash to sh, but this does not work 100% as bash switches to sh mode when arg(0) = "sh", I don't like that.
So I made a script that calls bash and replaced sh with that. But for some reason this can make problems with you boot process some times.
This is where bind mounts come in.
By adding a small init.d script that bind mounts my bash calling script with the sh binary (yes bind mount also works for files), the boot process gets to use it's bellowed sh while I get to use bash as default from everywhere. Because the script is mounted to the sh binary (Not linked), a reboot will reset it back to to original file.
Now we just add /system/etc/bash.bashrc and place an alias from sh to bash so that the custom script is not called more than it has to. Also I have added the option to add a custom .bashrc in /mnt/sdcard/ that is called from /system/etc/bash.bashrc, and a /system/etc/debian_chroot file support for those of you that has a chroot system installed.
Why use bash?
Well you can add custom layout to your shell, create/change global variables which normally only can be done from init.rc, create aliases, execute custom scripts and so on to make your shell environment just the way you like it.
The update.zip contains a bash binary that looks for /etc/bash.bashrc, the bash call script to replace sh, a bash.bashrc file that creates the android missing user variables and more, and the init.d script that mounts the bash call script.
Requirements
init.d support
busybox
Download
Bash Route 1.0.0 (MD5: ebb539f5d07944ead77439b89e76f524) - bash_route-signed.zip
Sh is actually a symlink to mksh, so just delete it, and replace (not true for /sbin/sh, its linked to busybox)
From my fingers to your eyez
cdesai said:
Sh is actually a symlink to mksh, so just delete it, and replace (not true for /sbin/sh, its linked to busybox)
From my fingers to your eyez
Click to expand...
Click to collapse
It does not matter. The point is when someone/something makes a call to sh, bash switches to sh mode. It does not matter if you link bash to sh, mksh or copies bash to either two or whatever. You need to replace arg(0) with "bash" instead of "sh". The only way to do this is to make a script that answers the call and redirects that call to bash along with the message (the rest of the arguments). That way arg(0) will be replaced with "bash" and the bash shell will run it's regular mode instead of the "sh" mode.
dk_zero-cool said:
It does not matter. The point is when someone/something makes a call to sh, bash switches to sh mode. It does not matter if you link bash to sh, mksh or copies bash to either two or whatever. You need to replace arg(0) with "bash" instead of "sh". The only way to do this is to make a script that answers the call and redirects that call to bash along with the message (the rest of the arguments). That way arg(0) will be replaced with "bash" and the bash shell will run it's regular mode instead of the "sh" mode.
Click to expand...
Click to collapse
Necrobumping this thread for a few reasons.
1.) You have posted in the Android Software and Hacking General section. I was looking for something similar to this for GS3-LTE. Your updater script is specifically for MTD devices....like i9000 ICS or so on.
2.) There are mistakes in your script to install. unmount is not a linux busybox command. umount is though.
I will try out your idea. Thanks
You got this still? The zip has gone down.

GUI Shortcut to Execute Linux Shell Script

To run a shell script quickly, I open Terminal Emulator and paste command from Clipper+ archives. Is there a faster way?
I want to tap a shortcut on homescreen to execute the shell script. Is it possible without diving into app development? Any hack etc?
Script manager in combination with the sm widget. I used to use it to run reboot scripts while on ICS.
Sent from my LG-P999 using xda premium
What if I want to have a shortcut to a script to be executed with Terminal Emulator? Not in/with any other program...
This seems to be not possible.

SManager - script executing fine manually, but not at boot

Greetings! I know there have been many topics on how to run scripts at boot time, most suggesting the safe way using Script Manager. But I'm encountering an odd issue:
I installed dropbear via opkg as described here and I wrote a script that would execute as root and start it. The script executes fine when I run it manually (either from SManager or from my terminal emulator using sh) and I am able to connect to my phone via ssh. However, when I set SManager to run the script at boot, the script executes fine, the processes are running (I can see them in the output of ps), the output from the processes (saved to log files) is the same as when I run them manually (and the connection can be established), but there is no TCP port associated with dropbear. I check using netstat - when I run the script manually, I can see the listening port, but not when the script is run automatically. Consequently, I cannot connect to my phone even though dropbear is running and reports it's listening on the port I specified. I tried adding a 2 minute delay in the script before dropbear is started (to allow the device to fully boot up) and I can confirm dropbear is started well after every other process, but the result is the same. I'm not sure if this is a problem with dropbear, SManager or something else.
I tried putting the script in /etc/init.d and making it executable, but it is not being run at all, I don't think scripts there are being read (there is no such entry in /init.rc that checks scripts in /etc/init.d).
I'm running SlimBean 4.2.2 on Samsung Galaxy S with 3.0.71-Semaphore_JB_2.9.18s kernel. Here follows the script:
Code:
#!/system/bin/sh
# dropbear and ssh are installed in /data/local/bin
export PATH=$PATH:/data/local/bin
sleep 1s
dropbear -p 42549 -v &>/sdcard/droplog
sleep 1s
# set up remote port forwarding (reverse ssh) to my PC so I can connect to my phone through its network's firewall
ssh -TfN -o "GlobalKnownHostsFile /data/.ssh/known_hosts" -p 4713 -R 4714:localhost:42549 [email protected]<my-PC's public IP address> &>/sdcard/sshlog &
anyone?
bump, anyone? Sorry if this is not in the right section of the forums
(delete)

[APP] SManager (Script Manager) - devwom

Hi,
I should want to copy files in a SManager script with keeping timestamps. To add -p option to cp, I use Busybox but if it works in console mode, it doesn't work in a script (permission denied). I can see I'm not root in a script (the command prompt is $ and not #). I tried to add "su" command in the script, and if it takes the capabilities, the script doesn't continue, I don't find what to do except kill the run.
I use rom AICP and Lollipop.
If somebody have a solution.
Thank you .
I've found, it needs to tap on "su" button (or to toggle on "su") before run.

Categories

Resources