How do get the full command line in ruby? -
how total command line in ruby?
$ rails c > $0 => "script/rails" > argv [] > `ps -eo "%p|$|%a" | grep '^\\s*#{process.pid}'`.strip.split("|$|")[1] => "/home/sam/.rvm/rubies/ruby-1.9.3-p194-perf/bin/ruby script/rails console"
is there cleaner ninja ps can same results?
to clarify, in case there confusion, want exact same output as:
`ps -eo "%p|$|%a" | grep '^\\s*#{process.pid}'`.strip.split("|$|")[1]
argv coming blank. $0 missing total path.
i'd use:
#!/usr/bin/env ruby puts "process id: #{ $$ }" puts `ps axw`.split("\n").select{ |ps| ps[ /\a#{ $$ }/ ] }
running within script outputs:
18222 s000 s+ 0:00.25 /users/foo/.rbenv/versions/1.9.3-p385/bin/ruby /users/foo/.rbenv/versions/1.9.3-p385/bin/rdebug /users/foo/desktop/test.rb ruby
No comments:
Post a Comment