Android Question Error with syntax using JKSSH2 Lib

Tyler

Member
Licensed User
Longtime User
Hey guys, I'm having an issue with quotes inside of quotes, hoping someone can help me. Here's my code:

B4X:
"screen -S gmod1 -p 0 -X stuff " & "" & command.text & "" & "`echo -ne '\015'`"""

Basically this sends text to a Linux screen session and hits ENTER(I've also posted on UNIX forums due to it being partially a UNIX/SHELL Issue but I think the syntax issue relates to B4A). If command.text is only one word, it works perfectly fine. If I want command.text to be two words I must manually add quotations around them within the app. I would like to add the quotation programmatically. I'm also racking my brain on changing the variable before this line of code. Something to the affect of

B4X:
command.text = """ & command.text & """

But that won't work either as it puts "command.text" into the string.


I also tried using QUOTE &.... But that Didn't work either


Any help on this would be greatly appreciated as I'm almost done and don't wanna be shutdown by a silly syntax error.
 
Last edited:

Tyler

Member
Licensed User
Longtime User
Now my next and final issue as the app is done but this keeps happening when not in Debug.

whenever the following code runs

B4X:
ssh.Initialize("ssh", hostname.Text, port.Text)
    ssh.authenticateWithPassword(username.Text, password.Text)
    ssh.execCommand("screen -X -S gmod1 kill", 12)


I get android.os.NetworkingOnMainThreadException
Continue?


Any suggestions?
 
Upvote 0

Tyler

Member
Licensed User
Longtime User
Okay, that didn't seem to work.. I'm fairly noob-ish when it comes to manifest editor, would you be so kind as to post an example?
 
Upvote 0

Tyler

Member
Licensed User
Longtime User
Oops, just noticed it in default lines in manifest. It would seem 16 hours of straight coding turned my brain to mush. I got it working though. How could I go about using httputils to do this instead?(due to SDK 4 being very old and kind of looks like crap).
 
Upvote 0

Tyler

Member
Licensed User
Longtime User
I ended up using this code and it works regardless of SDK version(above 9).

B4X:
Dim p As Phone
If p.SdkVersion >= 9 Then
  Dim r As Reflector
  r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
  r.Target = r.RunMethod("permitAll")
  r.Target = r.RunMethod("build")
  r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
      Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…