From: moonhkt on
Hi All

System :AIX 5.3

I prepare procedure for Database activity to other party. I want log
each command to a file.
how to log commad to a file ?

e.g.
ls -lt *.txt
ps -ef|grep pro
ps -ef|grep pro|wc -l
rm *.txt



moonhk
From: Bit Twister on
On Wed, 21 Apr 2010 22:30:14 -0700 (PDT), moonhkt wrote:
> Hi All
>
> System :AIX 5.3
>
> I prepare procedure for Database activity to other party. I want log
> each command to a file.
> how to log commad to a file ?
>
> e.g.
> ls -lt *.txt
> ps -ef|grep pro
> ps -ef|grep pro|wc -l
> rm *.txt

Not sure how much you want logged.
1. just result.
2. Command and result


For 1, it would be something like

ls -lt *.txt > result.log
ps -ef|grep pro >> result.log

For 2, it would be something like
echo ls -lt *.txt > result.log
ls -lt *.txt >> result.log
echo ps -ef|grep pro >> result.log
ps -ef|grep pro >> result.log

From: Chris F.A. Johnson on
On 2010-04-22, moonhkt wrote:
> Hi All
>
> System :AIX 5.3
>
> I prepare procedure for Database activity to other party. I want log
> each command to a file.
> how to log commad to a file ?
>
> e.g.
> ls -lt *.txt
> ps -ef|grep pro
> ps -ef|grep pro|wc -l
> rm *.txt

At the top of your script, put:

exec 2> "$HOME/log.$$"
set -v ## or: set -x


--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====
From: PDreyer on
On Apr 22, 7:30 am, moonhkt <moon...(a)gmail.com> wrote:
> Hi All
>
> System  :AIX 5.3
>
> I prepare procedure for Database activity to other party. I want log
> each command to a file.
> how to log commad to a file ?
>
> e.g.
> ls -lt *.txt
> ps -ef|grep pro
> ps -ef|grep pro|wc -l
> rm *.txt
>
> moonhk

The shell normally allow recording command history. Look at you shell
man page.
To log commands and output have a look at the man page of the script
command
From: Ed Morton on
On 4/22/2010 12:30 AM, moonhkt wrote:
> Hi All
>
> System :AIX 5.3
>
> I prepare procedure for Database activity to other party. I want log
> each command to a file.
> how to log commad to a file ?
>
> e.g.
> ls -lt *.txt
> ps -ef|grep pro
> ps -ef|grep pro|wc -l
> rm *.txt
>

man script