Search code examples
rubylinuxpopenprocfs

/proc directory script


I'm looking for a ruby script that accesses the /proc directory and saves the process ID and command line (cmdline) information in a file.


Solution

  • you may want to call ps instead of going to /proc.

    cmd=`ps -eo pid,cmd`
    o = File.open("output","w")
    o.write(cmd)
    o.close