On Thu, 10 Aug 2006, bwv549 wrote:

> How do I access built-in shell commands (like 'history' or 'fc') with a
> system call?
>
> Not what I was expecting:
>  % ruby -e 'puts `history`'
>      -e:1: command not found: history
>
> But this works fine:
>
>  % ruby -e 'puts `pwd`'
>      /home/john
>
> I've tried this:
>
>  % ruby -e 'system "history >tmp.tmp"; puts IO.read("tmp.tmp")'
>
> And no errors are generated, but there is nothing in tmp.tmp, either.
>
> Thanks



   system 'sh -c history'

however there really won't be one since the invocation of sh immediately
exits.

you may find my session lib helpful

   require 'session' # gem install session

   sh = Session::SH.new

   stdout, stderr = sh.execute 'ls'
   p sh.status

   stdout, stderr = sh.execute 'history'  # this will have 'ls' in it!
   p sh.status

regards.


-a
-- 
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama