Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>ban, I don't think what you are trying to do will work. The <code>/dev/fd/0</code> handle is different for each process (when you open it you basically make a copy/dup of the <code>fh</code> inherited by the parent process), so the file handle you open in perl will NOT be the same as for your bash.</p> <p>I believe you have (at least) two options here, though:</p> <ol> <li>Read your commands with the <code>while( &lt;STDIN&gt; )</code> approach, then store them to your file AND pass them to <code>system()</code>or <code>$qx()</code> to be executed by a shell, however, since this starts a shell for every command this only works for simple applications. You could work around this by opening a shell in a sub-child and connecting its STDIN/STDOUT filehandles with perl file handles you pipe new commands on and read out their input, though. See <code>perldoc perlopentut</code> (section Pipe Opens) and/or <code>IPC::Open2</code> (<a href="http://search.cpan.org/~rjbs/perl-5.18.0/ext/IPC-Open3/lib/IPC/Open2.pm" rel="nofollow">http://search.cpan.org/~rjbs/perl-5.18.0/ext/IPC-Open3/lib/IPC/Open2.pm</a>) for details. Combined with <code>Term::ReadLine</code> you can emulate the full input method of a shell and won't notice much of a difference, while logging all commands.</li> <li>Is there any reason why you don't just use <strong>bash's history feature</strong> (see for instance here: <a href="http://www.talug.org/events/20030709/cmdline_history.html" rel="nofollow">http://www.talug.org/events/20030709/cmdline_history.html</a>). By default every command you execute in an interactive session should be recorded in <code>~/.bash_history</code>, and you can access it with `history.</li> </ol> <p>If your application is security related, and you are trying to log everything that for instance <code>root</code> does on a system, then you might want to look into <code>sudo</code>, also.</p> <p>Hope this helps you, Christian</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload