Friday, August 12, 2005

Using the script command within a program

Using the script command
A
I want to use the script command within a shell script to capture the
commands and their output. I know I can redirect stdout/stderr to a
file but I would prefer to use the script command.

If I use it in a bash shell, the command starts up fine but I cannot
figure out how to stop it. I tried using exit, but it simply exits out
of the shell script not the command script.

Is this possible ? If so how ?

Thanks,
Kevin.

> If I use it in a bash shell, the command starts up fine but I cannot
> figure out how to stop it. I tried using exit, but it simply exits out
> of the shell script not the command script.

What you probably want is:

script -c /path/to/your/script /path/to/output/file

--

> What you probably want is:

> script -c /path/to/your/script /path/to/output/file

Assuming that your script has a '-c' option. Otherwise try

SHELL=/path/to/your/script script /path/to/output/file

and reset SHELL inside your script (You can save the value of SHELL if
needed in another variable).

Reply

0 Comments:

Post a Comment

<< Home