Recent

Author Topic: UnTerminal, Unit for Console process control  (Read 14514 times)

Edson

  • Hero Member
  • *****
  • Posts: 1114
UnTerminal, Unit for Console process control
« on: September 05, 2014, 09:01:43 pm »
'Unterminal' is a Unit for implementing Control of Console Process  in Lazarus with Prompt Detection.

This library, helps on control of the standard input/output of an process and  have the states of BUSY or READY.

https://github.com/t-edson/UnTerminal
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: UnTerminal, Unit for Console process control
« Reply #1 on: September 06, 2014, 10:09:21 am »
Thank you very much for your effort and sharing

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #2 on: September 06, 2014, 06:29:01 pm »
It's nothing. I use to create libraries, when develop some Apps. And some of then can be useful for other people, so I  share it.

This library was intended for use in Telnet/SSH clients. But I have used too for a SQL client.

For working with Telnet/SSH, it includes a VT100 emulator (in the unit termVT.pas), that support the basic escape sequences. I have successfully implemented a Telnet client with it.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

Roland Chastain

  • Guest
Re: UnTerminal, Unit for Console process control
« Reply #3 on: September 06, 2014, 09:06:09 pm »
Very interesting! I made a test with a chess engine using the UCI protocol (instead of cmd.exe) and it worked perfectly.

There was just one line to replace in your example project:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  //proc.Open('cmd','');
  proc.Open(txtProcess.Text, '');
end;

Congratulations for that unit.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: UnTerminal, Unit for Console process control
« Reply #4 on: September 06, 2014, 10:05:07 pm »
Very interesting - shame it's GPL (instead of say modified LGPL like Lazarus LCL) though as it limits use to GPL programs, but of course that's your prerogative.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #5 on: September 06, 2014, 11:31:55 pm »
There was just one line to replace in your example project:

It is fixed.

Very interesting - shame it's GPL (instead of say modified LGPL like Lazarus LCL) though as it limits use to GPL programs, but of course that's your prerogative.

I haven't analized deeply the licensing. But I will consider to use a more permisive license on future releases.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: UnTerminal, Unit for Console process control
« Reply #6 on: September 07, 2014, 10:30:36 am »
I haven't analized deeply the licensing. But I will consider to use a more permisive license on future releases.
Thanks!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: UnTerminal, Unit for Console process control
« Reply #7 on: September 08, 2014, 10:01:14 am »
Oh, perhaps useful when working with unterminal.

I've got a sample SSH client using synapse that works on Linux and Windows
https://bitbucket.org/reiniero/smalltools/src
directory SSHClient
(not sure about license compatibility with UnTerminal though I normally license as MIT X11 which is fine when combining with GPL)

Had a quick look at Edson's repositories which also showed SSH integration but only mentioned PLink on Windows
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #8 on: September 08, 2014, 08:32:09 pm »
Here is an example of using Unterminal for a Telnet/SSH Client:

https://github.com/t-edson/Tito-s-Terminal

But it use "plink.exe" for the connection, so FAIK it's onlly for Windows.

Sadly, I have not a Linux machine for test.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

Roland Chastain

  • Guest
Re: UnTerminal, Unit for Console process control
« Reply #9 on: September 09, 2014, 10:00:22 am »
I didn't really understand what is the usage of the AutoConfigPrompt procedure (the "Detect Prompt" button in the example project). Could someone be kind enough to explain?

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #10 on: September 09, 2014, 03:49:06 pm »
It's for configuring automatically, the prompt detection of the unit. It takes the last line of the terminal and configure the unit for to detect that line like a prompt.

It's not mandatory, but if you want  that the unit knows when the process is "Ready" for to accept commands, you should configure the prompt detection.

UnTerminal have the ability for to detect when the prompt appear on the terminal, scanning line by line for to see if it matches with the Prompt configuration.

There are 3 ways for to configure the Prompt detection:

1. Setting manually, the parameters of the detection.
2. Using the method AutoConfigPrompt (like in the Example).
3. Using the event OnChkForPrompt, for to define a custom routine (like RegExp comparing).
« Last Edit: September 09, 2014, 03:52:16 pm by Edson »
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #11 on: September 09, 2014, 06:28:36 pm »
Version 0.5 released:
https://github.com/t-edson/UnTerminal

News:
* Prompt detection improved.
* New event OnFirstReady()  implemented.
* New property for to change the scan frequency.
* Improved the translation of some names on the source.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

Roland Chastain

  • Guest
Re: UnTerminal, Unit for Console process control
« Reply #12 on: September 09, 2014, 07:19:39 pm »
Thank you for the useful explanation about prompt detection. Now I see.

I am making a demo of the UCI chess protocol with your unit. It works very well.

I will have a look at the latest version.


Roland Chastain

  • Guest
Re: UnTerminal, Unit for Console process control
« Reply #13 on: September 10, 2014, 08:04:58 pm »
Hello! I finished my UCI demo. Thanks again for your unit. Maybe one day (if God lends me life) I could make a chess GUI using UnTerminal.  :)

Edson

  • Hero Member
  • *****
  • Posts: 1114
Re: UnTerminal, Unit for Console process control
« Reply #14 on: September 11, 2014, 12:01:08 am »
It's good to know that it's useful for you. I see you're using the latest version.

I don't know about UCI, but it seems interesting. I hope you could make your chess GUI soon.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

 

TinyPortal © 2005-2018