alwaysbusy Expert Licensed User Longtime User Apr 7, 2017 #1 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
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
B billzhan Active Member Licensed User Longtime User Apr 7, 2017 #2 Try B4X: ' it should be sh0.Initialize("sh0", "./BLEScan0", Array As String("'"& PiCodeHex &"'")) Upvote 0
alwaysbusy Expert Licensed User Longtime User Apr 7, 2017 #3 @billzhan I could've sworn I tried that, as indeed that is the correct way. Just had to change in my script to use $1 $2 $3 instead. Thanks for the extra eyes Upvote 0
@billzhan I could've sworn I tried that, as indeed that is the correct way. Just had to change in my script to use $1 $2 $3 instead. Thanks for the extra eyes