Expect.NET version 1.0.0 released

A few days ago I released Expect.NET version 1.0.0. As it is first public release of this library, I will start with short introduction, then describe its functionality and how to get that.

Few words about expect and Expect.NET

Expect.NET is port of the expect scripts functionality for .NET framework. Original expect scripts are used to control interactive shell applications. Expect page on Wikipedia includes some good examples how to automate telnet, ftp and sftp sessions using original expect scripts.

Expect.NET version 1.0.0 is distributed under The MIT License.

Thanks to Expect.NET one can, in easy way using C# (I haven’t tested it with VB.NET…), execute shell applications which needs interactions with user. Below is short example how looks code which starts Windows command-line terminal and changes few times directory.

//Execute command cmd.exe and control it
Spawn spawn = new SpawnCommand("cmd.exe");
// wait for prompt and display received printout 
spawn.expect(">", s => Console.WriteLine("got: " + s));
// issue command 'cd c:\' - note that <enter> must be explicitly write as '\n'
spawn.send("cd c:\\\n");
// wait for prompt then issue command 'cd Users'
spawn.expect(@">", s => spawn.send("cd Users\n"));
// wait for string 'c:\Users>' then display 'done' and received printout
spawn.expect(@"c:\\Users>", s => Console.WriteLine("done\n" + s));

Using this library is pretty straight-forward (especially for those who used original expect):

  • spawn shell command
  • wait for string then execute some action
  • wait for string then execute some action
  • etc…

Technical info and how to get that

Expect.NET version 1.0.0 internally uses async and await functionality so it requires .NET framework version 4.5 or higher.

Compiled library can be found on NuGet: https://www.nuget.org/packages/Expect.NET/

Source code can be found on GitHub: https://github.com/wiwanek/Expect.NET

Current plans and work progress can be found on JazzHub: https://hub.jazz.net/project/iwanek/ExpectNET

Expect.NET version 1.0.0 available functionality

  • Control of local shell applications
  • Waiting for expected string
  • Configurable timeouts

2 thoughts on “Expect.NET version 1.0.0 released

  1. Pingback: expect timeout - Expect.NET introduction | Wojtek Iwanek Blog

  2. Pingback: Expect for .NET 1.0.1 released | Wojtek Iwanek Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.