B4J Question jShell, first character in parameter lost (first char becomes 0)

alwaysbusy

Expert
Licensed User
Longtime User
I have a simple shell that passes one parameter (with spaces in it).

B4X:
Dim PiCode As String = "001"
Dim PiCodeHex As String = conv.HexFromBytes(conv.StringToBytes(PiCode, "UTF-8"))
PiCodeHex = PiCodeHex.SubString2(0,2) & " " & PiCodeHex.SubString2(2,4) & " " & PiCodeHex.SubString2(4,6)
  
Log(PiCodeHex)   '----> 30 30 31
  
Dim sh0 As Shell
sh0.Initialize("sh0", "./BLEScan0", Array As String(PiCodeHex))
sh0.WorkingDirectory = "/home/pi/OneTwo/"
sh0.Run(10000) 'set a timeout of 10 seconds

The bash script (relevant code):
B4X:
sudo hcitool -i hci0 cmd 0x08 0x0008 19 02 01 06 03 03 aa fe 11 16 aa fe 10 00 02 6f 6e 65 2d 74 77 6f 07 $1 00 00 00 00 00 00

The result is:

sudo hcitool -i hci0 cmd 0x08 0x0008 19 02 01 06 03 03 aa fe 11 16 aa fe 10 00 02 6f 6e 65 2d 74 77 6f 07 00 30 31 00 00 00 00 00 00

Running this manually in the console, it is correct:

B4X:
$ ./BLEScan0 "30 30 01"

'result
sudo hcitool -i hci0 cmd 0x08 0x0008 19 02 01 06 03 03 aa fe 11 16 aa fe 10 00 02 6f 6e 65 2d 74 77 6f 07 30 30 31 00 00 00 00 00 00
 

billzhan

Active Member
Licensed User
Longtime User
Try
B4X:
' it should be
sh0.Initialize("sh0", "./BLEScan0", Array As String("'"& PiCodeHex  &"'"))
 
Upvote 0
Top