2011-12-30 14 views
0

システムコマンドで実行されるコマンドがあります。 シェルに渡されたものをログに記録できますか?Rubyとシステム入力

P.S.私は、あなたが、「引用符での問題」を有する言及したあなたは、システムコマンドに

command = "whoami" # store the command as string 
puts command  # print it before you execute it 
system(command)  # execute it in the shell 
+0

"通過したもの"とはどういう意味ですか?システムコマンドが返す結果は? – Vapire

+0

シェルで呼び出される正確な文字列 –

+0

コマンドの出力をキャプチャしますか? –

答えて

1

それを送っている前に、あなたは、単に文字列を印刷することができますqoutesに問題=)

1

を持っています。二重引用符を意味すると思いますか?

command = %Q{echo "double quoted string"} # store the command as string 
puts command        # print it before you execute it 
system(command)       # execute it in the shell 
関連する問題