Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

am tryinng to run unix script and trying to get terminal name on output. i can n

ID: 3604605 • Letter: A

Question

am tryinng to run unix script and trying to get terminal name on output. i can not figure out what's the wrong can you please help me to find the mistakes?

abc=$(who | grep $$ | awk '{print $2}')
first=$1 middle=$2 last=$3
fullname="$first $middle $last"
curname=$fullname
echo "Your full name is" $curname
"and you are logged into " $abc
echo "Thank you for running
this script."

output is " Your full name is rohi desai and you are logged in to pts/1"

I am getting pts/2 insted of pts/1 so i need help to fix it please.

Explanation / Answer

abc=$( ps -p $$ | tail -n 1 | awk '{print $2}' )

first=$1 middle=$2 last=$3

fullname="$first $middle $last"

curname=$fullname

echo "Your full name is" $curname "and you are logged into " $abc

echo "Thank you for running his script."