Sha256: 714d7c48dd9a28ac6f59065b58d2660305d40685572ba3f1865a50c21d19f684
Contents?: true
Size: 596 Bytes
Versions: 1
Compression:
Stored size: 596 Bytes
Contents
require 'pty' def launch_and_interact_with_terminal begin PTY.spawn("bash") do |stdout, stdin, pid| # Send a command to the terminal stdin.puts "echo 'Hello from Ruby!'" # Read the output of the command stdout.each do |line| puts line break if line.include?("Hello from Ruby!") end # You can continue to interact with the terminal here # ... # Ensure to exit the spawned shell stdin.puts "exit" end rescue PTY::ChildExited => e puts "The child process exited!" end end launch_and_interact_with_terminal
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
markdown_exec-1.6 | lib/pty1.rb |