Skip to content

Commit 038f7b6

Browse files
committed
usage
1 parent 3b41f96 commit 038f7b6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ Or install it yourself as:
2020

2121
$ gem install net-telnet
2222

23+
## Usage
24+
25+
### Log in and send a command, echoing all output to stdout
26+
27+
```ruby
28+
localhost = Net::Telnet::new("Host" => "localhost",
29+
"Timeout" => 10,
30+
"Prompt" => /[$%#>] \z/n)
31+
localhost.login("username", "password") { |c| print c }
32+
localhost.cmd("command") { |c| print c }
33+
localhost.close
34+
```
35+
36+
### Check a POP server to see if you have mail
37+
38+
```ruby
39+
pop = Net::Telnet::new("Host" => "your_destination_host_here",
40+
"Port" => 110,
41+
"Telnetmode" => false,
42+
"Prompt" => /^\+OK/n)
43+
pop.cmd("user " + "your_username_here") { |c| print c }
44+
pop.cmd("pass " + "your_password_here") { |c| print c }
45+
pop.cmd("list") { |c| print c }
46+
```
47+
2348
## Development
2449

2550
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.

0 commit comments

Comments
 (0)