- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Session is closing
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 07:48 AM
05-01-2002 07:48 AM
Session is closing
I wrote a small scipt which will give a small menu.And the last option is exit.It is working fine when I am just excuting like this.
./bv_tools
but when I tried to source into my shell it is killing my telnet screen and closing all the windows
. ./bv_tools
---------------------------------
Here is the code which I wrote for exit:
echo " x) Exit"
echo
echo
echo " Your Selection : \c "
read CHOICE
if [ "${CHOICE}" = x ]
then
clear
exit 0
else
clear
(( k = "$CHOICE - 1" ))
${MENUCOMMAND[$k]}
fi
-----------------------------------
What could be the reason???
Please help me to solve the issue.
Thanks in advance.
-Chandramani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 07:57 AM
05-01-2002 07:57 AM
Re: Session is closing
This is a case of the shell doing exactly what you ask it to do.
When you execute as ./bv_tools, bv_tools is run as a separate process so that the exit only applies to the shell executing bv_tools BUT when your source it as '. ./bv_tools' then this is run in the current shell and as soon as you exit you actually exit the current shell. NEVER use exits in sourced files (unless you truly want to exit the foreground process).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 07:58 AM
05-01-2002 07:58 AM
Re: Session is closing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 08:04 AM
05-01-2002 08:04 AM
Re: Session is closing
If you run ./bv_tools,
the shell will create a child process, so your 'exit' command will simply tell the child process to exit, and you will be returned to the shell.
But if you run '. ./bv_tools', it's as if you type each line of your script at the command line. So, your 'exit' command will actually exit your shell.
If you need to test your script with the "dot" command, you can run 'sh' to open another shell first. Then '. ./bv_tools will terminate by exiting that shell, and you will be returned to your original shell.
Mlade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 08:07 AM
05-01-2002 08:07 AM
Re: Session is closing
Thanks for the clue. Can you give any alternative or other way to exit from the menu ,but not from the telnet session.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 08:13 AM
05-01-2002 08:13 AM
Re: Session is closing
sh -c ./bv_tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 10:39 AM
05-01-2002 10:39 AM
Re: Session is closing
print " 1) Say Hello "
print " 2) Say Goodbye "
print " 3) Exit "
print -n "Please select your choice: "
read choice
case $choice in
1) say_hello_function;;
2) say_goodbye_function;;
3) leave_function;;
*) print " Sorry, bad choice "
esac
# you cannot use exit
# as the name of a
# function as like a meta
# character it has special meaning
you can source these functions in a couple of different ways ( ie: functions in the same file above the case statement or functions in a "referenced" file like .filenamerc.
I personally like the .filenamerc method but it really doesn't matter.
jiin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 11:20 AM
05-01-2002 11:20 AM
Re: Session is closing
HTH
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 07:05 PM
05-01-2002 07:05 PM
Re: Session is closing
I solved that problem by putting die() in place of exit 0.
I don't know whether it is correct or not,but it is working for me.If anyone knows more about die(),please explain little more.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 07:28 PM
05-01-2002 07:28 PM
Re: Session is closing
