[ale] Dumb Shell Scripting Question.....

Charles Shapiro charles.shapiro at nubridges.com
Thu Dec 9 15:05:51 EST 2004


Perhaps  the script(1) command is what you want. It's very handy (along
with "set -x" for debugging shell scripts. I leave why you'd write a
shell script long enough to require debugging as an Exercise for the
Reader.


**
[devel at cshapiro tmp]script /tmp/foo.out
Script started, file is /tmp/foo.out
bash-2.05$ echo Hey Mom!
Hey Mom!
bash-2.05$ uname -a 
Linux cshapiro.numethods.com 2.4.18 #5 Thu May 2 11:17:38 EDT 2002 i686
unknown
^d
bash-2.05$ Script done, file is /tmp/foo.out
[devel at cshapiro tmp]cat /tmp/foo.out
Script started on Thu Dec  9 15:01:06 2004
bash-2.05$ echo Hey Mom!
Hey Mom!
bash-2.05$ uname -a 
Linux cshapiro.numethods.com 2.4.18 #5 Thu May 2 11:17:38 EDT 2002 i686
unknown
bash-2.05$ 
Script done on Thu Dec  9 15:01:14 2004
[devel at cshapiro tmp]
**

-- CHS

On Thu, 2004-12-09 at 14:14, Joe Sechman wrote:
> I was wondering if it was possible to echo the name of a running
> command interactively in the shell to where the output contains the
> name of the command and the resulting command output - resulting  in a
> log of commands (w/the help of tee, etc...) that were run matched with
> their output.
> 
> For example:
> 
> $ ls -la | tee -a myoutput
> ls -la | tee -a myoutput:
> total 32
> drwxrwxr-x    2 sechmanj sechmanj     4096 Oct 21 13:32 .
> drwx------   29 sechmanj sechmanj     4096 Dec  9 10:08 ..
> -rw-rw-r--    1 sechmanj sechmanj      579 Jun 14 13:43 franki.c
> -rw-rw-r--    1 sechmanj sechmanj      190 May 11  2004 example.txt
> ...
> 
> $ cat test | tee -a myoutput
> cat test | tee -a myoutput:
> This is a test file
> 
> $ cat myoutput
> ls -la | tee -a myoutput:
> total 32
> drwxrwxr-x    2 sechmanj sechmanj     4096 Oct 21 13:32 .
> drwx------   29 sechmanj sechmanj     4096 Dec  9 10:08 ..
> -rw-rw-r--    1 sechmanj sechmanj      579 Jun 14 13:43 franki.c
> -rw-rw-r--    1 sechmanj sechmanj      190 May 11  2004 example.txt
> ...
> cat test | tee -a myoutput:
> This is a test file
> 
> I've got the sense that I'm missing something blaringly
> obvious.......Thanks in advance for any help!!



More information about the Ale mailing list