help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] counter for executed commands in non interactive mode?


From: Stephane Chazelas
Subject: Re: [Help-bash] counter for executed commands in non interactive mode?
Date: Tue, 19 May 2015 13:30:33 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-05-19 10:23:18 +0200, Meike Stone:
> 2015-05-18 17:47 GMT+02:00 Stephane Chazelas <address@hidden>:
[...]
> > What number should it give you after:
> >
> > { cmd1; cmd2; } | cmd3 | cmd4
> > (cmd1; cmd2); env cmd3
> > sh -c 'cmd1; cmd2'
> > for i in 1 2 3; do
> >   cmdx "$i"
> > done
> >
> > ?
> 
> name this script and check:
> 
> strace -f -e execve ./test.sh 2>&1 >/dev/null | grep execve | wc -l

Then the shell can't give you that number since it can't know
for instance that "sh" or "env" above will execute another (or
several other) commands.

You'll have to use "auditd" or that "strace"-based approaches.
(note the grep has a -c option for counting).

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]