forked from Fudge/gltail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References Fudge#21, allowing local commands to be run and parsed
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module GlTail | ||
module Source | ||
|
||
class Command < Base | ||
config_attribute :source, "The type of Source" | ||
config_attribute :command, "The command to run" | ||
|
||
def init | ||
@lines = [] | ||
Thread.new do #start thread | ||
begin | ||
puts "Running command #{command}" | ||
PTY.spawn( command ) do |stdin, stdout, pid| | ||
begin | ||
# Do stuff with the output here. Just printing to show it works | ||
stdin.each { |line| | ||
@lines.push(line) | ||
} | ||
rescue Errno::EIO | ||
# puts "Errno:EIO error, but this probably just means " + | ||
# "that the process has finished giving output" | ||
end | ||
end | ||
rescue PTY::ChildExited | ||
puts "Command has exited!" | ||
end | ||
end #end thread | ||
end | ||
|
||
def process | ||
unless @lines.length == 0 | ||
parser.parse(@lines[0]) | ||
@lines.delete_at(0) | ||
end | ||
end | ||
|
||
def update | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require 'pty' | ||
module GlTail | ||
module Source | ||
|
||
|