|
|
|
Tuesday, 05 October 2010 13:44 |
Search for all running processes using a regular expression pattern and return PIDs for all processes matching it ...
Quick version ... there is probably a better way to do this ...
module Process
class << self
def search(pattern)
result = Dir['/proc/[0-9]*/cmdline'].inject({}) do |h, file|
if (process = File.read(file).split(/\000|\s+/).first)
process = File.basename(process).gsub(/\W/, '')
(h[process] ||= []).push(file.match(/\d+/)[0].to_i)
end
h
end.map { |k, v| v if k.match(pattern) }.compact.flatten
result if result.any?
end
end
end
Simple use-case:
irb(main):184:0> `ps x -o cmd | awk '{ print $1 }' | grep -i bash | wc -l`
=> "8\n"
irb(main):185:0> Process.search(/bash/).size
=> 8
irb(main):186:0> `ps x -o cmd | awk '{ print $1 }' | grep -i sh | wc -l`
=> "17\n"
irb(main):187:0> Process.search(/sh/).size
=> 17
irb(main):188:0>
 Read more: |
|
|
Wednesday, 25 August 2010 04:52 |
// description of your code here
open editplus.exe, input as follow
wget "http://sms.api.bz/fetion.php?username=myTelNo&password=myPass&sendto=yourFreindTelNo&message=Hello DZone"
save as Fection.bat
configure EditPlus Tool, Command: cmd /c , Arg: $(FilePath)
then Ctrl + 1 to run Fection.bat Read more: |
|
Sunday, 14 March 2010 07:15 |
The following S-Rscript RSF job uses insertBefore to insert a paragraph above the cmd box.
Resources:
- insertBefore [about.com]
Screenshot: http://twitxr.com/image/318217/
 Read more: |
|
|
|
|
|
|