Operating System - HP-UX
1834207 Members
2673 Online
110066 Solutions
New Discussion

Re: validate a user in a script

 
Patrice Blanchard_2
Frequent Advisor

validate a user in a script

Hi,

what is wrong with this picture?

user=`whoami`
if $user = "bsp150"
then
user="blanchap"
else
fi

All i want to do is change the variable user to blanchap if user that is running the script is bsp150.

i'm missing something.

regards

PB
3 REPLIES 3
Slawomir Gora
Honored Contributor

Re: validate a user in a script

Hi,

try this

#!/bin/sh
user=`whoami`
if [ "$user" = "bsp150" ]
then
user="blanchap"
fi
Pete Randall
Outstanding Contributor

Re: validate a user in a script

Patrice,

Try this:

user=`whoami`
echo $user
if [ $user = "bsp150" ]
then
user="blanchap"
fi
echo $user


Pete

Pete
Biswajit Tripathy
Honored Contributor

Re: validate a user in a script

How about:

usr=$(whoami | sed 's/^bsp150$//')
echo ${usr:="blanchap"}

- Biswajit

:-)