Is running .sh files allowed (without Rooting Phone)

giga

Well-Known Member
Licensed User
Longtime User
Help Please.

When i try this

B4X:
Sub manualstart_Click()

Dim i As Intent    
i.Initialize(i.ACTION_CALL, "file:///sdcard/user/config.sh")    
i.SetType("bin/sh")    
Try       
StartActivity(i)    
Catch        
ToastMessageShow("Cannot start file.", True)
Log(i)
End Try

End Sub
I get the error
(Intent) Intent { act=android.intent.action.CALL dat=file:///sdcard/user/config.sh typ=bin/sh flg=0x20000 }

Thanks for any help.

I tried Phone.Shell

and got this error

java.io.IOException: Error running exec(). Command: [config.sh, /sdcard/user/config.sh] Working Directory: null Environment: null
 

giga

Well-Known Member
Licensed User
Longtime User
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User
How do you know rsync is not running?
You can type each line of the script in terminal emulator to test it line-by-line.

Thanks for the reply thedesolatesoul.

When I type rsync in terminal emulator its says "rsync not found"
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User

Thanks,

In Terminal I cd to mnt/sdcard/rsync(where I placed rsync binary)

tried ./rsync

permission denied :sign0148:
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User

:BangHead: Sorry to take up your time.

ls -ltr returns unknown option -t Aborting
chmod +x rsync returns Bad Mode

Also is I try su

i get UID 10049 not allowed to su
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User

I can do ls -l returns a directory list

chmod 777 rsync. returns Operation not permitted.

Thanks for your diligence :sign0013:
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
ls -l rsync returns

the file name rsync, this is a binary file. Can I push a rsync.exe file into the sdcard. I was told that android can't run .exe files.
ls -l should also return the permissions in the form of rwxrwxrwx or something like that. If there are no 'x' in the permission then the file is not executable.
Android cannot run windows binaries (.exe).
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User
ls -i rsync

Yes the line returned is:

----rwxr-x system sdcard_rw 308024 2013-01-02 23:04 rsync

but chmod wont change it because user permissions, in terminal i could probably change it through ADB but that wont be possible for each phone this will used on.

Thanks thedesolatesoul for you efforts. the other option i have is to send the sh to a app like terminal and use it as a initial command.

B4X:
Try
Dim isy As Intent
Dim new As PackageManager
 
' application must declare jackpal.androidterm.permission.RUN_SCRIPT In manifest 
isy.Initialize(isy.ACTION_MAIN, "")
isy = new.GetApplicationIntent("jackpal.androidterm.RUN_SCRIPT")
 isy.putExtra("jackpal.androidterm.iInitialCommand","/mnt/sdcard/config.sh")  
If isy.IsInitialized Then
StartActivity(isy)
 End If
   Catch
  ToastMessageShow ("Failed to launch app! Is it installed?", True)
  Log(isy)
 End Try

but i get Failed to launch app! Is it installed because B4A doesnt like RUN_SCRIPT at the end of androidterm. if i take it off the other app loads. :sign0148: p.s i also declared it in the manifest.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Make sure you added the correct permission in the manifest.
Your code should be:

B4X:
Dim isy As Intent
 
' application must declare jackpal.androidterm.permission.RUN_SCRIPT In manifest 
isy.Initialize("jackpal.androidterm.RUN_SCRIPT", "")
isy.putExtra("jackpal.androidterm.iInitialCommand","/mnt/sdcard/config.sh")  
StartActivity(isy)
Dont use Try/Catch for now, so that you can see the errors/exceptions in debug.
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User
I think i added it correctly to the manifest.

I added this line.
B4X:
<uses-permission android:name="jackpal.androidterm.permission.RUN_SCRIPT" />

I will remove the try and catch

Thanks
B4X:
isy.Initialize("jackpal.androidterm.RUN_SCRIPT", "")
isy.putExtra("jackpal.androidterm.iInitialCommand","/mnt/sdcard/config.sh")

returns permission denied
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…