From: Bruno Sousa on 9 Aug 2010 13:32 Hi everyone, How can I write a ruby script in order to capture error messagens from bash commands? if I do this: out = `rm /var/mail/teste2` Errors like "rm: cannot remove `/var/mail/teste2': No such file or directory" won't be stored in "out" string. How can I do that? regards -- Posted via http://www.ruby-forum.com/.
From: Brian Candler on 9 Aug 2010 14:06 Bruno Sousa wrote: > out = `rm /var/mail/teste2` > > Errors like "rm: cannot remove `/var/mail/teste2': No such file or > directory" won't be stored in "out" string. > > How can I do that? out = `rm /var/mail/teste2 2>&1` Otherwise look at open3 in the stdlib, if you want to get stdout and stderr separately. -- Posted via http://www.ruby-forum.com/.
From: Bruno Sousa on 9 Aug 2010 16:00 Brian Candler wrote: > Bruno Sousa wrote: >> out = `rm /var/mail/teste2` >> >> Errors like "rm: cannot remove `/var/mail/teste2': No such file or >> directory" won't be stored in "out" string. >> >> How can I do that? > > out = `rm /var/mail/teste2 2>&1` > > Otherwise look at open3 in the stdlib, if you want to get stdout and > stderr separately. Thanks! -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: place string into paste buffer? Next: windows stty IRB question |