ruby net-ssh gemを使用してJuniper M10iルータを変更したいと考えています。しかし、 "configure"を送信した後、私は設定コマンドを送ることができません。ruby gem net-sshを使用してJuniperルータを設定する
たとえば、SSH経由でルータにログインした後、私は以下の3つのコマンドを発行したいと思います。net-sshのライブラリを使用して
configure
show system
exit
を、私は成功せず、次の試してみました:
Channel open.
FAIL: show system
FAIL: exit
Data Entering configuration mode
!!!!!!!!!!
Channel is closing!
私が正しくPASんので、どのように:私は次の出力を得ることが実行されると
# net-ssh (2.3.0)
require 'net/ssh'
session = Net::SSH.start(host, user, :password => password)
session.exec!('term length 0')
session.exec!('term width 0')
channel = session.open_channel do |ch|
puts "Channel open."
ch.on_close do |ch|
puts "Channel is closing!"
end
ch.on_data do |ch, data|
puts "Data #{data}!!!!!!!!!!"
end
ch.exec "configure" do |ch, success|
puts "FAIL: configure" unless success
end
ch.exec "show system" do |ch, success|
puts "FAIL: show system" unless success
end
ch.exec "exit" do |ch, success|
puts "FAIL: exit" unless success
end
end
session.loop
s "configure"の後の "show system"コマンド?
は解決:
を私は次のポストに出くわし:ポストに基づいてhttps://stackoverflow.com/a/6807178/152852
は、 "プロンプト" を指定しないようにとにかくありますか? "プロンプト"を正しく指定しないと、スクリプトがハングします。 –
デフォルトのプロンプトを指定する必要はなく、デフォルトのプロンプトと一致する可能性があります。 –
おかげで、あなたのポストを見るまで、プロンプトとぶら下がっているスクリプトの種類がしばらく私を困惑させました。 +1されました –