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

前端 未结 5 1548
谎友^
谎友^ 2020-12-05 05:03

I am trying to use script command for logging a bash session.

The script command is executed from withing a bash script but as soon as it i

5条回答
  •  广开言路
    2020-12-05 05:12

    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.

提交回复
热议问题