login about faq

Hi, I'm trying to use the ssh component on a VB 6.0 project and I want to run a "tail -f /var/log/messages" on te remote server and retrive the log lines as they are written. How can I accomplish that? because I read that all the methods wait for a certain criteria (message, channel closed, etc) to retrieve the messages from the channel.

Regards, Max

asked May 26 '17 at 15:12

shad's gravatar image


It's actually very easy. :)

A remote shell session is a logical channel within the connection to the SSH server. (Many shell sessions can be running simultaneously, each with its own logical channel.)

You can refer to this example for how to start a shell session: https://www.example-code.com/vb6/ssh_quick_shell_session.asp

Once the shell session is started, anything your program sends on the logical channel (indicated by the channel number) becomes stdin for the session. In other words, your VB6 program is like a person typing at the shell command prompt. Likewise, the shell session's stdout (and stderr) is what is sent back on the logical channel.

So.. your program would send the "tail -f /var/log/messages" command, making sure to also send the newline. This is like someone typed that command and pressed return. The command starts running, and the output will get sent back on the logical channel.

Your VB6 program can then start a timer that fires periodically (perhaps 4 times per second is plenty), that calls ssh.ChannelPoll to see if anything is available on the channel (i.e. if the "tail -f" sent anything to stdout/stderr). If so, then call ssh.ChannelRead to get whatever is available. Then call ssh.GetReceivedText to access the data that was received by the call to ChannelRead. (And of course, append the text to your display.)


answered May 29 '17 at 16:57

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: May 26 '17 at 15:12

Seen: 816 times

Last updated: May 29 '17 at 16:57

powered by OSQA