[Gambas-user] PEEK and managing ssh

Benoît Minisini g4mba5 at gmail.com
Tue Feb 11 02:02:48 CET 2020


Hi,

In the last commit, I have added two new features:

1) A PEEK command, that allows to peek some bytes from a stream without 
removing them, so that they are available to the next READ instruction.

Note that if you issue another PEEK, without having called READ before, 
then the bytes are lost. In other words, the second PEEK does not read 
the same bytes again.

2) A new class named "Terminal". The name is not very good, it may 
change if I find or if someone suggests something better.

This class encapsulates a Process object, and provides an Expect() 
method that allows to tell what to answer to the process when it issues 
a specific prompt.

This is useful for commands that work by asking passwords to the user 
without being able to take it from its arguments.

For example, if you want to run an "scp" command from Gambas, you will 
do that:

   hProcess = Exec ["scp", ... ] For Input Output As "Process"

   hTerminal = New Terminal(hProcess) As "Terminal"

   hTerminal.Expect("(yes/no*)?", "yes")
   hTerminal.Expect(":", "the password for my ssh key")

   hProcess.Wait

Comments, suggestions and questions are welcome!

Regards,

-- 
Benoît Minisini


More information about the User mailing list