Ejecutando comandos del sistema¶
Kernel.system¶
1>> Dir.getwd
2=> "/home/gomix/Ruby/system"
3>> system("ls -l")
4total 0
5-rw-rw-r-- 1 gomix gomix 0 dic 18 11:05 system.rb
6
7>> system("lh")
8=> false
backticks¶
1>> Dir.getwd
2=> "/home/gomix/Ruby/system"
3>> `ls -l`
4=> "total 0\n-rw-rw-r-- 1 gomix gomix 0 dic 18 11:05 system.rb\n"
5
6>> `lh`
7(irb):14: command not found: lh
8=> ""
Kernel.exec¶
1>> exec("ls -l")
2total 0
3-rw-rw-r-- 1 gomix gomix 0 dic 18 11:05 system.rb
1>> r = %x[ls -l]
2=> "total 0\n-rw-rw-r-- 1 gomix gomix 0 dic 18 11:05 system.rb\n"
3
4>> r = %x[lh]
5(irb):4: command not found: lh
Pendientes¶
Referencias¶