Skip to content

Instantly share code, notes, and snippets.

@mvidner mvidner/cheetah-y2log.rb
Last active Nov 30, 2017

Embed
What would you like to do?
Cheetah using the YaST log
#!/usr/bin/ruby
require "cheetah"
require "yast"
Cheetah.run("ls", "-la", "/var/lib/empty", logger: Yast::Y2Logger.instance)
# another way: "log" becomes a shortcut for Yast::Y2Logger.instance
include Yast::Logger
begin
Cheetah.run("ls", "-la", "/no/such/file", logger: log)
rescue Cheetah::ExecutionFailed
log.error "Not there I guess"
end
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:158 Executing "ls -la /var/lib/empty".
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:206 Standard output: total 8
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:206 Standard output: drwxr-xr-x 2 root root 4096 May 10 2017 .
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:206 Standard output: drwxr-xr-x 96 root root 4096 Aug 15 10:04 ..
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:178 Status: 0
2017-11-30 08:57:50 <1> hal.example.org(4291) [Ruby] lib/cheetah.rb:158 Executing "ls -la /no/such/file".
2017-11-30 08:57:50 <3> hal.example.org(4291) [Ruby] lib/cheetah.rb:206 Error output: ls: cannot access '/no/such/file': No such file or directory
2017-11-30 08:57:50 <3> hal.example.org(4291) [Ruby] lib/cheetah.rb:178 Status: 2
2017-11-30 08:57:50 <3> hal.example.org(4291) [Ruby] snippets/cheetah-y2log.rb:13 Not there I guess
@mvidner

This comment has been minimized.

Copy link
Owner Author

commented Nov 30, 2017

So, this is actually a reinvention of a (previously undocumented) wheel:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.