Bash script: Using “script” command from a bash script for logging a session?

I don't think script is doing what you think it is doing. Your shell script did not stop. It is still running.

You are getting a prompt because script is spawning a new shell The use case for script is: start script (spawns a new shell) do commands exit shell (logout) and drop to previous shell examine or print logfile created by script So basically script is working as expected. You will have to find another way to achieve what you want You can log the execution of your script like this:! /bin/bash exec > logfile 2>&1 set -x FOO=BAR echo $FOO Explanation: exec > logfile 2>&1 redirects stdin and out to logfile set -x makes bash print every command before executing it Example: $ .

/foo. Sh $ cat logfile + FOO=BAR + echo BAR BAR Alternatively you can do it like this:! /bin/bash FOO=BAR echo $FOO Then: $ script -c "bash -x foo.Sh" Script started, file is typescript + FOO=BAR + echo BAR BAR Script done, file is typescript $ cat typescript Script started on Mi 18 Mai 2011 01:05:29 CEST + FOO=BAR + echo BAR BAR Script done on Mi 18 Mai 2011 01:05:29 CEST.

I don't think script is doing what you think it is doing. Your shell script did not stop. It is still running.

You are getting a prompt because script is spawning a new shell. The use case for script is: start script (spawns a new shell) do commands exit shell (logout) and drop to previous shell examine or print logfile created by script So basically script is working as expected. You will have to find another way to achieve what you want.

You can log the execution of your script like this: #! /bin/bash exec > logfile 2>&1 set -x FOO=BAR echo $FOO Explanation: exec > logfile 2>&1 redirects stdin and out to logfile set -x makes bash print every command before executing it Example: $ . /foo.Sh $ cat logfile + FOO=BAR + echo BAR BAR Alternatively you can do it like this: #!

/bin/bash FOO=BAR echo $FOO Then: $ script -c "bash -x foo. Sh" Script started, file is typescript + FOO=BAR + echo BAR BAR Script done, file is typescript $ cat typescript Script started on Mi 18 Mai 2011 01:05:29 CEST + FOO=BAR + echo BAR BAR Script done on Mi 18 Mai 2011 01:05:29 CEST.

– limp May 14 at 14:28 @limp: I updated my answer. – lesmana May 17 at 23:07.

Your bash script is still running, but it has spawned a new interactive shell. The bash script is waiting for script to complete, which will only happen when the interactive shell is terminated (either by being killed, or by the user typing exit). To make the command after script be logged by script, do it like this: script build_log -c 'echo -e "* This line should appear inside the /"build_log/" log file..."' However, script will stop running after running that command.To run multiple commands inside script, put those commands inside another bash script and specify that bash script as the command to run to the -c option.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions