Operating System - HP-UX
1828582 Members
2537 Online
109982 Solutions
New Discussion

script to NOT logout a user after...

 
Cindy Wolford
Frequent Advisor

script to NOT logout a user after...

Hi there,

On 10.20, I am creating a user that when he logs in, it will run a script automatically.

This part works great. Script is called from his .profile and this works fine.

My problem is that when the user exits the script, it logs him out.

I'd like this user to be able to get to the prompt should he need to.

Right now, he can't. If he exits the script (by answering "Yes" to my prompt "Do you wish to exit"), he is exited but logged off the system. I'd like to have him able to exit this script and be sitting at the prompt.

Any suggestions? TIA!
9 REPLIES 9
John Meissner
Esteemed Contributor

Re: script to NOT logout a user after...

Could you attach a copy of the script for us to look at?
All paths lead to destiny
James R. Ferguson
Acclaimed Contributor

Re: script to NOT logout a user after...

Hi Cindy:

Provide an option in your script to launch a shell:

# sh

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: script to NOT logout a user after...


My best guess is that you are
executing your script in .profile this way

. myscript.sh
rather than
myscript.sh

In the former, myscript.sh is not a separate process; it is executed as part of the same shell; thus an exit in myscript.sh exits the shell. In the latter case, myscript.sh executes as a separate process and an exit from the child returns to the parent.
If it ain't broke, I can fix that.
Cindy Wolford
Frequent Advisor

Re: script to NOT logout a user after...

Sure....

This .profile is exactly like mine except for this is the last line for him:

# Set default menu
exec /d01/bin/admin01.sh

Here is admin01.sh:

:
MFG=/d01/86e
DB_prod=/d02/prod

export DB_prod MFG

stty intr '^c'

DLC=/d01/dlc
PATH=$PATH:$DLC

export PATH DLC

while :
do
clear

1 = Production Database
2 = SMENU
q = Quit


Enter Selection :\c"
read rsp
case "$rsp" in
1) $DLC/bin/_progres -db $DB_prod -pf $MFG/client.pf ;;
2) /d01/bin/smenu ;;
q|Q) exit ;;
esac

echo "Press enter to continue -->\c"
read x
done

If I run this script from my prompt by typing /d01/bin/admin01.sh....the script works fine and when I say "Q" to quit, I am dropped to the prompt....perfect.

But, like I said, I've put this into his .profile and when he logs in, the script runs....but when he says "Q" to quit, he is logged out.

Any ideas? TIA!!!!
Sridhar Bhaskarla
Honored Contributor

Re: script to NOT logout a user after...

Hi,

As Clay indicated, since you are running it as part of your profile, "exit" is exiting the shell (which is executing .profile also) and hence you are being logged out.

You can do it two ways. Take out the code and put it a seperate script and embed it in profile. You don't need to call it with . as it will be executed in a different shell.

The other way is to give one more option "say 3"

Put another case in your case statement and enter /usr/bin/sh (or ksh) for the option 3.

However, I would suggest to go with the first option.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sridhar Bhaskarla
Honored Contributor

Re: script to NOT logout a user after...

Sorry. I didn't see your exec call. You do have it as a seperate script.

Take out exec and you should be fine.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Cindy Wolford
Frequent Advisor

Re: script to NOT logout a user after...

Thank you everyone for all of your help!

I just took at the exec and it is perfect!

THANK YOU THAnK YOU THAnk YOU!!!!

John Meissner
Esteemed Contributor

Re: script to NOT logout a user after...

Do you need the exec command to launch your script? If you put the script in there without it I believe it will run. Try that
All paths lead to destiny
Sridhar Bhaskarla
Honored Contributor

Re: script to NOT logout a user after...

Cindy,

There is a protocol to express thanks in these forums.

;-)

-Sri
You may be disappointed if you fail, but you are doomed if you don't try