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 }
Sub Activity_Create(FirstTime As Boolean)
Dim p As Phone
File.WriteString(File.DirRootExternal, "1.sh", "#!/bin/sh" & CRLF & "echo test")
Dim out, err As StringBuilder
out.Initialize : err.Initialize
p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "1.sh")), out, err)
Log("out: " & out)
Log("err: " & err)
End Sub
Note that you should post the full error message from the logs (you can copy with right click).
Sub Activity_Create(FirstTime As Boolean)
Dim p As Phone
File.WriteString(File.DirRootExternal, "1.sh", "#!/bin/sh" & CRLF & "echo test")
Dim out, err As StringBuilder
out.Initialize : err.Initialize
p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "1.sh")), out, err)
Log("out: " & out)
Log("err: " & err)
End Sub
Note that you should post the full error message from the logs (you can copy with right click).
Sub manualstart_Click()
Dim prs As Phone
Dim Command, Runner As String
Dim out, err As StringBuilder
Dim Result As Int
out.Initialize : err.Initialize
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirRootExternal & "/config", "config.sh")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
Result = prs.Shell("sh", Array As String(Runner), out, err)
Log("out: " & out)
Log("err: " & err)
End Sub
Thanks for the reply. I am using the emulator, Not an actual device yet. Strangely If i use another program to run the same script it works like (BusyBox). But not in B4A :BangHead:
As far as I can tell, I got this one to work without the su .
B4X:
Sub manualstart_Click()
Dim prs As Phone
Dim out, err As StringBuilder
out.Initialize : err.Initialize
prs.Shell("sh", Array As String(File.Combine(File.DirRootExternal & "/config", "config.sh")), out, err)
Log("out: " & out)
Log("err: " & err)
End Sub
The problem was in the config.sh I used writeline instead on write to create the sh which caused new lines for each word vertically.
I am not getting the error now, this is the log now.
out:
err:
But I can't see if the sh(script) is running.
Is there a way of showing a DOS Shell or Android Terminal to display the progress????
Thanks NJDude
Good Idea, At this stage I will try that at least for testing.
I was hoping there was something included in Android that I could use as GetApplicationIntent.
I could send a script to and show the progress on the screen.
But I cant get it to work with jackpal.androidterm.RUN_SCRIPT
It does come up jackpal.androidterm (without RUN_SCRIPT) :sign0148: but nothing but SOM(start of message)
B4X:
Sub manualstart_Click()
Try
Dim Intent1 As Intent
Dim pm As PackageManager
Intent1 = pm.GetApplicationIntent("jackpal.androidterm.RUN_SCRIPT")
Intent1.AddCategory("DEFAULT")
Intent1.PutExtra("jackpal.androidterm.iInitialCommand", "echo 'Hi there!'")
If Intent1.IsInitialized Then
StartActivity (Intent1)
End If
Catch
ToastMessageShow ("Failed to launch app! Is it installed?", True)
End Try
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim p As Phone
File.WriteString(File.DirRootExternal, "1.sh", "#!/bin/sh" & CRLF & "echo test")
Dim out, err As StringBuilder
out.Initialize : err.Initialize
p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "1.sh")), out, err)
Log("out: " & out)
Log("err: " & err)
End Sub
Thanks Erel,
The example I tried when you sent it to me works.
out: echo test
err:
I added "#!/bin/sh" to the begining of my config.sh and tried it but nothing happened.
Does this "#!/bin/sh" have to be on a separate line?