B4J Question Help with SHELL

Num3

Active Member
Licensed User
Longtime User
Hi all,

First post :)

I am trying to execute the following code (which works with other programming languages PHP, C etc), but i cannot get a return in B4J, help is appreciated!
B4X:
    Dim s_input As String ="2008-03-10;2008-03-10T15:58:00;FT 1/1;28.07;"
   'Dim s_query As String = "/c echo.|set/p=" +Chr(34) + s_input + Chr(34) + " | openssl dgst -sha1 -sign chave_privada.txt | openssl enc -A -base64"

   'params.Add("/c echo. | set /p=" & Chr(34) & s_input & Chr(34) &" | openssl dgst -sha1 -sign chave_privada.txt | openssl enc -A -base64")
   Log("/c echo.|set /p=" & Chr(34) & s_input & Chr(34) &" | openssl dgst -sha1 -sign chave_privada.txt | openssl enc -A -base64")
 
   params.Add("/c")
   params.Add("echo.|set")
   params.Add(".|")
   params.Add("set")
   params.Add("/p=" & Chr(34) & s_input & Chr(34))
   params.Add("|")
   params.Add("openssl")
   params.Add("dgst")
   params.Add("-sha1")
   params.Add("-sign")
   params.Add("chave_privada.txt")
   params.Add("|")
   params.Add("openssl")
   params.Add("enc")
   params.Add("-A")
   params.Add("-base64")

   shl.Initialize("shl", "cmd.exe", params)
   shl.WorkingDirectory = File.DirApp
    Try
       ' Run with disabled timeout
       shl.Run(-1)
   Catch
       Log(LastException.Message)
   End Try
 

Num3

Active Member
Licensed User
Longtime User
@Daestrum I have the sub, posted below.
It just reports:
Waiting for debugger to connect...
Program started.
Success
Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. Todos os direitos reservados.

It should have reported:
Waiting for debugger to connect...
Program started.
Success
F8952fjEClltx2tF9m6/QTFynFjSuiboMslNZ1ag9oR5iIivgYYa0cNa0wJeWXlsf8QQVHUol303hp7XmIy5/kFOiV0v8QH6SF0Q5zNsDtpeFh2ZJ256y0DkJMSQqCq3oSka+9zIXXRkXgEsSv6VScCYv8VTlIcGjsablpR6A4=

B4X:
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    If Success And ExitCode = 0 Then
        Log("Success")
        Log(StdOut)
    Else
        Log("Error: " & StdErr)
    End If
    ExitApplication
End Sub
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Is it a non-ui application ?
 
Upvote 0

Num3

Active Member
Licensed User
Longtime User
It is UI, but need to use openssl to generate the hash for those strings.
I have used this with success:
B4X:
shl.Initialize("shl","cmd.exe",Array As String("/c echo. | openssl dgst -sha1 -sign chave_privada.txt < test1.txt | openssl enc -base64"))
Instead of pipping the string into openssl i wrote it to a file (test1.txt), then pipped it's contents, but i would like to avoid writing it to a text file...
 
Upvote 0
Top