mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	sample/pty/expect_sample.rb: Update sample
* Fix regexp capture scope bug. * Specify frozen_string_literal: true. * Use passive mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									411083a9a6
								
							
						
					
					
						commit
						2cc0461bfa
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
# frozen_string_literal: true
 | 
			
		||||
#
 | 
			
		||||
# sample program of expect.rb
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -23,8 +24,17 @@ PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
 | 
			
		|||
    username = 'guest'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  r_f.expect(/^(Name).*: |(word):|> /) do
 | 
			
		||||
    w_f.puts($1 ? "ftp" : $2 ? "#{username}@" : "cd pub/ruby")
 | 
			
		||||
  r_f.expect(/^Name.*: /) do
 | 
			
		||||
    w_f.puts("ftp")
 | 
			
		||||
  end
 | 
			
		||||
  r_f.expect(/word:/) do
 | 
			
		||||
    w_f.puts("#{username}@")
 | 
			
		||||
  end
 | 
			
		||||
  r_f.expect(/> /) do
 | 
			
		||||
    w_f.puts("cd pub/ruby")
 | 
			
		||||
  end
 | 
			
		||||
  r_f.expect("> ") do
 | 
			
		||||
    w_f.print "pass\n"
 | 
			
		||||
  end
 | 
			
		||||
  r_f.expect("> ") do
 | 
			
		||||
    w_f.print "dir\n"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue