R
Richard Sandoval
Hello,
I have a ruby script that executes a linux command however the command
returns a question:
This will update 1 entry, continue? [y/N]:
I can see this output in when in debug mode for the script. How can I
pass a y and return/enter automatically for each time this question
comes up? I tried to add system(echo y) and puts "\r" to send a y and do
a return but no success. Any pointers?
Here is an example of my small script:
require 'yaml'
require 'nventory'
nvclient = NVentory::Client.newdryrun => true, :debug => true, :server
=> 'http://nventory.local')
mdb = YAML::load_file('mdb_dump.yml')
mdb.each_key do |server|
setdata = { :name => "#{server}", :hardware_profile_id => 4, :status_id
=> "#{mdb[server]['status']}"}
nvclient.set_objects('nodes',{},setdata,'jsmith')
end
mdb = YAML::load_file('mdb_dump.yml')
mdb.each_key do |server|
system("opsdb --dry-run --server nventory.local nv --exactget
name=dhcpserver.local --addtonodegroup=temp1,temp2")
system(echo y)
puts "\r"
I have a ruby script that executes a linux command however the command
returns a question:
This will update 1 entry, continue? [y/N]:
I can see this output in when in debug mode for the script. How can I
pass a y and return/enter automatically for each time this question
comes up? I tried to add system(echo y) and puts "\r" to send a y and do
a return but no success. Any pointers?
Here is an example of my small script:
require 'yaml'
require 'nventory'
nvclient = NVentory::Client.newdryrun => true, :debug => true, :server
=> 'http://nventory.local')
mdb = YAML::load_file('mdb_dump.yml')
mdb.each_key do |server|
setdata = { :name => "#{server}", :hardware_profile_id => 4, :status_id
=> "#{mdb[server]['status']}"}
nvclient.set_objects('nodes',{},setdata,'jsmith')
end
mdb = YAML::load_file('mdb_dump.yml')
mdb.each_key do |server|
system("opsdb --dry-run --server nventory.local nv --exactget
name=dhcpserver.local --addtonodegroup=temp1,temp2")
system(echo y)
puts "\r"