Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jun 2002 10:46:03 -0400 
From:      "Morse, Richard E." <REMORSE@PARTNERS.ORG>
To:        "'steve@northnetworks.ca'" <steve@northnetworks.ca>, freebsd-questions@freebsd.org
Subject:   RE: Logging commands...
Message-ID:  <375F68784081D511908A00508BE3BB1701EF1B2D@phsexch22.mgh.harvard.edu>

next in thread | raw e-mail | index | archive | help
Steve Bertrand [mailto:steve@northnetworks.ca] wrote:

> I am running FreeBSD 4.5 and am about to config and install 
> amanda backup 
> software (www.amanda.org).

Cool!  I've got this up and running in my small installation (backing up
about 6 machines, mostly Solaris)...
 
> How can I output the actual commands to a text file without 
> sending the 
> result of a command to the file?  Is it possible?

The two most commonly used shells ([t]csh and bash) have a 'history'
mechanism, which stores the 'n' most recently used commands to a file.  In
tcsh, the file is ~/.history.  It may be different under bash.  You should,
in theory, be able to set your history to be a large enough value, then
later on go and copy out what you need from this file.

It's not perfect, but it's straightforward.

An alternative might be to use the following perl script [UNTESTED]:

-----------
#!/usr/bin/perl -w
use strict;
use warnings;

my $out_file_name = shift @ARGV;
open(my $out, ">>", $out_file_name) or die("Can't open $out_file_name: $!");
print $out "Script from ", scalar(localtime), "\n\n";
my $done = 0;
while(!$done) {
	chomp(my $curr_dir = `pwd`);
	print $curr_dir, " %";
	chomp(my $in = <>);
	print $out $in, "\n";
	if ($in eq 'exit') {
		$done++;
	} else {
		`$in`;
	}
}
close($out);
__END__
---------------

I have no clue if this will properly output data to the console -- you may
have to spend more than about 3 minutes writing it to get it to show you
what's happening...

HTH,
Ricky

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?375F68784081D511908A00508BE3BB1701EF1B2D>