[Suggestion] Execute command on the sh files

Support for Android version of Total Commander

Moderators: Stefan2, white, sheep, Hacker

Post Reply
Cvulturbo
Junior Member
Junior Member
Posts: 29
Joined: 2013-02-09, 14:25 UTC
Location: eu ru

[Suggestion] Execute command on the sh files

Post by *Cvulturbo » 2013-04-24, 07:18 UTC

cannot assign the command to run the sh files by setting the internal associations.

tried assign .sh files with commands:

/system/bin/sh
/system/xbin/busybox
busybox sh

but unsuccessfully.

each time showing the error

"Cannot open file/folder!
test.sh"

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

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37417
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2013-04-25, 12:34 UTC

The command must be either sh or su. The parameters are the actual command you want to use.
Author of Total Commander
http://www.ghisler.com

Cvulturbo
Junior Member
Junior Member
Posts: 29
Joined: 2013-02-09, 14:25 UTC
Location: eu ru

Post by *Cvulturbo » 2013-04-26, 09:28 UTC

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 test.sh got message
"Cannot open file/folder!
test.sh"

my test.sh have two lines:
#!/system/bin/sh
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/test.sh'

thanks in advance.

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37417
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2013-04-29, 13:35 UTC

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.
Author of Total Commander
http://www.ghisler.com

Cvulturbo
Junior Member
Junior Member
Posts: 29
Joined: 2013-02-09, 14:25 UTC
Location: eu ru

Post by *Cvulturbo » 2013-04-29, 17:48 UTC

works perfect in this way. thank you. even shows the result. fantastic! :D

jmwap
Member
Member
Posts: 117
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap » 2016-09-09, 10:40 UTC

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.

thanks

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37417
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2016-09-12, 09:50 UTC

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/test.sh

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.
Author of Total Commander
http://www.ghisler.com

jmwap
Member
Member
Posts: 117
Joined: 2008-03-23, 12:40 UTC

Post by *jmwap » 2016-09-14, 09:43 UTC

worked perfectly with the new explanation, thanks

GeroZ
Junior Member
Junior Member
Posts: 18
Joined: 2005-01-13, 22:05 UTC

Re: [Suggestion] Execute command on the sh files

Post by *GeroZ » 2019-06-07, 12:03 UTC

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 test.sh, so its full path is /storage/emulated/0/test.sh.

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/test.sh". 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/test.sh" 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?

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37417
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [Suggestion] Execute command on the sh files

Post by *ghisler(Author) » 2019-06-11, 14:36 UTC

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.
Author of Total Commander
http://www.ghisler.com

Post Reply