2017-10-13 10 views
0

コードを実行したときに何もせずに残した最初のオプションを選択した理由を理解できません。 私のクリスタルスクリプトのコードは以下の通りです。メニューからコールコードを呼び出して実行します。

require "colorize" 
class Application 

    def initialize 
    mainMenu 
    end 

    def mainMenu 
    puts "you are going to install the software?" 
    puts " 1: To install the soft you have to be root".colorize.fore(:red).bold 
    puts " 2: Modify module" 

    case gets 
    when "1" 
     puts "installation of the software.." 
     install_soft 

    when "2" 
     puts "you chose option2" 
    end 
    end 

    Application.new 
end 

これは、メソッドinstall_softを使用したmy installモジュールのコードです。 彼は正しく私のputs " you are .."を印刷するが、それは何も:(まあ

module InstallSoft 
    def install_soft 
    puts "you are in def install_soft " 
    output = IO::Memory.new 
    Process.run("bash", args: {"eole/lib/bash_scripts/installation.sh"}, output: output) 
    output.close 
    output.to_s 
    end 
end 

答えて

0

私は出力とライブでスタックを参照するには解決策を見つけた:真

Process.run("lib/bash_scripts/installation.sh", shell: true, output: true, error: true) 
0

、それはあなたがメモリIOプロセスの標準出力を収集?何をすべき文字列に変換しません。

あなたの場合プロセスの標準出力をアプリケーションの標準出力に出力したい場合は、転送する必要があります(メモリIOの代わりにSTDOUTを使用するか、メモリIOの内容を標準出力に出力してください)。

0

i私が使用したソリューションを見つけた

Process.run("lib/bash_scripts/installation.sh", shell: true, output: output) 
      output.close 
      output.to_s 

が、一瞬のために、私は私のスクリプトの出力を得るカント:(

+0

'output'を印刷する必要がありますあなたの出力を出してください。また、インストールスクリプトがキャプチャする出力を生成するようにしてください。 –

関連する問題