user2997779
user2997779

Reputation: 397

Bash terminal closes after running a script

I am running the following script:

#!/bin/bash
argumente=$#

if [ $argumente -ne 2 ]
then    echo "Trebuie dati doi parametri"
fi

if test -e $1
then    if  test -e $2
        then
                fisier1="$1"
                fisier2="$2"
                exec 0< $fisier1
                exec 1> $fisier2
                tr '[:lower:]' '[:upper:]'
        else echo "Nu exista al doilea fisier dat ca argument"
        fi
else echo nu    
fi

And it outputs the right thing, but after that, the terminal closes itself. I think It`s because I redirected the output. How can I redirect the output back to the terminal after script ends?

Upvotes: 2

Views: 315

Answers (1)

Newbrict
Newbrict

Reputation: 283

You're sourcing the script by running it via

. scriptname arg1 arg2

You have to execute the script like this

./scriptname arg1 arg2

Upvotes: 4

Related Questions