Auto input credentials when prompted in ruby -


i newbie ruby. have our install process automated in ruby. facing issue on making ruby script adapt changes in shell script.

execute "update_imports" cwd import_home command "./import.sh #{download_dir}/#{import_file} #{user} #{shellwords.escape(password)}" action :run end 

the import.sh modified such asks username , password (doesn't take username , password arguments earlier)

earlier: ./import.sh /tmp/importtest.xml test1 password  now: ./import.sh /tmp/importtest.xml username: test1 password: 

i want modify ruby file adapt change. can suggest best way so? tried searching , learning being pretty new ruby, clueless.

you can use open3 in ruby standard library:

download_dir = "./test/dir" shell_command = "./import.sh #{download_dir}" username = "username" password = "password"  open3.popen3("shell_command") |input, output, error, thread|   input.puts(username) # answers username prompt   input.puts(password) # answers password prompt   puts output.read # prints output of script far end 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -