1

My Shell script include series of steps for example first step

App=  read -p "### Please enter Application name " 
Env = read -p "### Enter Enviornment name (Dev,test)"

second step

cd /opt/Weblogic/
mkdir $App
mkdir $Env

Third Step

cp /tmp/weblogic/* /opt/weblogic/$App/$Env/*

So my question is how can I record what user is entering each time? Is there a way I can store the user the whole input and output to something call temp.txt? This way I can review to find out which user has enterred which input.

I hope my question is clear.

1

You could wrap it all in a subshell and tee or tee -a to output to temp.txt.

e.g.

(
read -p "### Please enter Application name " App
read -p "### Enter Enviornment name (Dev,test)" Env
echo "App: $App"
echo "Env: $Env"

cd /opt/Weblogic/
mkdir $App
mkdir $Env

cp /tmp/weblogic/* /opt/weblogic/$App/$Env/*

) | tee -a temp.txt

The -a on tee will append to the temp.txt for each execution. You can remove it if you want it to start fresh each time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.