Search code examples
rubyspawnpty

Ruby pty spawn shell command fails


I am running a shell command via pty, and I get this error:

No such file or directory - fork failed (Errno::ENOENT)

This is the command I run:

PTY.spawn("telnet localhost 12345") do |r_f,w_f,pid|
    w_f.print "ls"
end

Any suggestions?


Solution

  • you have no telnet command available directly. you can try one of several ways to handle it

    1. specify full path to command
    2. make sure the path environment variable (usually PATH) that you have in the environment used by ruby contains the folder where telnet resides.