Page 1 of 1

[Suggestion] Execute command on the sh files

Posted: 2013-04-24, 07:18 UTC
by Cvulturbo
cannot assign the command to run the sh files by setting the internal associations.

tried assign .sh files with commands:

busybox sh

but unsuccessfully.

each time showing the error

"Cannot open file/folder!"

it would be great to have the execute command from the drop-down menu. :)

Posted: 2013-04-25, 12:34 UTC
by ghisler(Author)
The command must be either sh or su. The parameters are the actual command you want to use.

Posted: 2013-04-26, 09:28 UTC
by Cvulturbo
Thanks for your reply.

tried to create association for .sh files in "Internal associations" list, and then in window "Edit association: .sh" in the editbox entered " sh" as you say. but unfortunately. when taping on file got message
"Cannot open file/folder!"

my have two lines:
touch /mnt/sdcard/hello_world.txt

please explain what command should i use for executing scripts. is there any command line keys like %path %filename or something?

for example txt associated with command "Jota Text Editor:jp.sblo.pandora.jota:.Main". looks like non standard command line format.

it would be nice to have native support for executing sh files with one internal command.
(like this one):
try {
Runtime.getRuntime().exec(new String[] {"su","-c", "'sh ", ourfile, "'"});

su -c 'sh /mnt/sdcard/'

thanks in advance.

Posted: 2013-04-29, 13:35 UTC
by ghisler(Author)
Sorry, you cannot run shell scripts from TC via single click. What I meant is that you can create a button with the sh command as the command, and the shell script or %P%N for the first selected file as the parameters.

Posted: 2013-04-29, 17:48 UTC
by Cvulturbo
works perfect in this way. thank you. even shows the result. fantastic! :D

Posted: 2016-09-09, 10:40 UTC
by jmwap
I am trying to do this too, but I cannot. Says:

Can't execute: permissions denied

So I am trying to change permissions of my .sh file to have Execute permissions, I do that in the Properties, and although it says "Function succeeded" the permissions have not changed....

what am I missing? I am root, of course.


Posted: 2016-09-12, 09:50 UTC
by ghisler(Author)
Where is the file located? Normally you cannot set permissions in internal or external SD-Cards, e.g. under /mnt/sdcard or /storage/emulated/0

Normally it should work when you specify the button settings like this:
Command: su or sh
Parameters: sh /mnt/sdcard/

The command just runs an interactive shell in root or user mode. The Parameters contain commands piped to that shell - it's as if you executed them manually by typing the command. By putting sh in front, the shell script can run even when it's not set to execute.

Posted: 2016-09-14, 09:43 UTC
by jmwap
worked perfectly with the new explanation, thanks

Re: [Suggestion] Execute command on the sh files

Posted: 2019-06-07, 12:03 UTC
by GeroZ
I'm sorry for unearthing this ancient thread, but it's exactly what I'm looking for – but I don't seem to be able to carry it out.


So I've got a .sh file that is proven to work just fine with Alif Software "Terminal" (com.qamar.terminal) in which I actually created and edited it – let's call it, so its full path is /storage/emulated/0/

Again in above mentioned "Terminal", I can execute it both right from the editor, and also on the interactive command line – by entereing "sh /storage/emulated/0/". That works just fine, so both the path is correct and the script is doing its designated job.

Now I understand that to be able to run the script from inside TCMD, I should add a new button to the button bar (I finally found that capability), select "Internal Command", enter "sh" into the "Command" field, and as above "sh /storage/emulated/0/" into the "Parameters" field.

… However: The shell script is not executed. I don't receive any kind of error message, but it doesn't seem to do anything either. It should perform a few file move operations, so I'd see if it had done its job, which it didn't.

What am I doing wrong?

Re: [Suggestion] Execute command on the sh files

Posted: 2019-06-11, 14:36 UTC
by ghisler(Author)
Total Commander already calls an interactive shell with "sh" in the command field.
Try leaving out sh from the parameters. If this doesn't work, try giving sh with its full path in the parameters field.