Last active
November 30, 2017 08:23
-
-
Save mvidner/acb5a1111e47628391909b1c468c0202 to your computer and use it in GitHub Desktop.
Cheetah using the YaST log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Author
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
Docs: