There is a log file and my shell runs windows commands such as ‘type log_file’ or ‘tail -f log_file’. ( with windows tail binary ).
So, I want to see the latest log entries in GUI automatically. The new entries are displayed in a textarea.
– calling method
dim getLogDataShell_Run As New getLogDataShell
finalCommand = " cd " + DirectoryName + " & " + "type " + FileName
getLogDataShell_Run.Execute finalCommand
If getLogDataShell_Run.ErrorCode <> 0 Then
Msgbox "getLogDataShell_Run Error: " + Str(getLogDataShell_Run.ErrorCode)
Else
Logging("Check: getLogDataShell_Run executed : " + FileName )
End If
– DataAvailable event
Dim ResultBuffer As String
ResultBuffer = Me.ReadAll
Logging("DEBUG: getLogDataShell / DataAvailable event")
MainWindow.MainContainerScreen.JOBMonitorList_area.AppendText ResultBuffer
Logging("DEBUG: ResultBuffer(getLogDataShell): " + ResultBuffer)
It seems that the shell command is executed, but DataAvailable event never got fired.
“‘tail’ is not recognized as an internal or external command,
operable program or batch file.”
This works:
[code]
Dim x as string
Dim i as integer
Dim s as shell
x=“cd c:\temp\ & type License.txt”
s=New Shell
s.Execute x
i=s.ErrorCode
If i <> 0 then msgbox str(i)
TextArea1.text=s.result[/code]
I suggest typing the command you are trying to run, in full, in notepad, then copy and paste into a command processor ( cmd ) to see if you have your systax correct. OR get your program to put it on the clipboard and try it manually in a command processor.
‘tail.exe’ is not a native command in Windows. Downloaded in other site.
As you can see in the below, the shell command works fine, but thing is that I don’t see any data in .Result.
When I use ‘type’ command, I can.
I found a tail command. If you use “-f” on this one it still waits and does not close. Maybe that is the one you have. Try without the -f bit. What error does the shell return. This works. Why do you use “start”?
[code] Dim x as string
Dim i as integer
Dim s as shell
As for ‘start’ command, I tried to run the shell command as a background. It doesn’t matter here I guess.
Yes, ‘tail’ or ‘tail -100’ command would work. But, I need to incorporate into a Timer to get the latest data of a log file.
I wanted to do that with ‘-f’ option without Timer.
I believe as a workaround I can just use ‘tail’ and Timer.
Still wondering why Shell doesn’t get data with ‘-f’ option.