- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Help Needed for Script
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
12-22-2005 04:44 PM
12-22-2005 04:44 PM
I write a one script for quit the application , if i quit the db it should comeout from telnet sessions itself and also CTRL-C should not work because only quit only can quit the session
below the script i tried but if i quit its going to $ prompt and not comeout from telnet session
pls help anyone
dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
exit 0
else
getdb
fi
}
getdb()
{
clear
echo "\n\n\n\n\n
Enter the db name you wish to connect to \n or quit to exit : \c"
read DB123
dbcheck
}
getdb
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 04:56 PM
12-22-2005 04:56 PM
Re: Help Needed for Script
You can try two options,
#1. Try logout, it will logout from script shell.
#2. Create an alias for it, just like "./myscript.sh; exit"
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:01 PM
12-22-2005 05:01 PM
Re: Help Needed for Script
Can you give some example how to do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:02 PM
12-22-2005 05:02 PM
Re: Help Needed for Script
To disable operation of ^c, you need to set the trap to ignore ^c.
trep '' 3
3 is interrupt signal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:09 PM
12-22-2005 05:09 PM
Re: Help Needed for Script
{
if [ $DB123 = "quit" ]
then
clear
break
exit 0
else
getdb
fi
}
logout # logout is quit is entered.
getdb()
{
trap '' 3 # to ignore the ^c
clear
echo "\n\n\n\n\n
Enter the db name you wish to connect to \n or quit to exit : \c"
read DB123
dbcheck
}
getdb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:09 PM
12-22-2005 05:09 PM
Re: Help Needed for Script
http://groups.google.com/group/comp.unix.questions/browse_thread/thread/7454d8d229e84167/09b8b71f5423e734?lnk=st&q=how+to+logout+from+a+shell+script%3F&rnum=1&hl=en#09b8b71f5423e734
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:23 PM
12-22-2005 05:23 PM
Re: Help Needed for Script
Trap is not working pls help me if u hv example pls tell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 05:31 PM
- Tags:
- trap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 07:27 PM
12-22-2005 07:27 PM
Re: Help Needed for Script
Trap is working now my script is disabled the CTRL-C but how i should comeout from current telnet session thro' script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 07:38 PM
12-22-2005 07:38 PM
Re: Help Needed for Script
You need to logout from the shell or kill it's PPID within the script. Take a look at the link which i have posted earlier on how to accomplish this.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 08:43 PM
12-22-2005 08:43 PM
Re: Help Needed for Script
trap "exit;" 1 2 3 # to ignore trap signals 1 2 3
It will execute exit command on getting signal 1 or 2 or 3.
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 08:52 PM
12-22-2005 08:52 PM
Re: Help Needed for Script
change trap statement as follows.
trap 'echo "logging out";logout' 1 2 3
If you mean, when quit is entered, then it should logout, then do it as follows.
dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
breat #-->modified this.
else
getdb
fi
}
logout #--> modified this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 08:52 PM
12-22-2005 08:52 PM
Re: Help Needed for Script
change trap statement as follows.
trap 'echo "logging out";logout' 1 2 3
If you mean, when quit is entered, then it should logout, then do it as follows.
dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
break #-->modified this.
else
getdb
fi
}
logout #--> modified this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 08:59 PM
12-22-2005 08:59 PM
Re: Help Needed for Script
Replied twice. Is it one for new year greetings to karthik. ;)
PS: Not relavent to post.
Typing related with post--->
You can execute a function or command with trap "part"
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 09:11 PM
12-22-2005 09:11 PM
Re: Help Needed for Script
But actually what i need CTRL-C should be disbled(this is working) and also if user quit the database and same time user should comeout from telnet sessions and user should never go to $ prompt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 09:21 PM
12-22-2005 09:21 PM
Re: Help Needed for Script
dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
# Killing that shell
kill -9 $(who -mu | awk '{ print $7;}')
else
getdb
fi
}
Try it out.
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 09:24 PM
12-22-2005 09:24 PM
Re: Help Needed for Script
Ok, we do it as follows.
Modify the function as follows.
dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
echo "${DB123}" > $HOME/.some_file
exit 0
else
getdb
fi
}
Also modify the .profile/the script that starts the menu script as follows.
exit_status_of_script=$(< ~/.some_file)
if [[ ${exit_status_of_script} = "quit" ]]
then
exit 0
else
continue
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2005 10:48 PM
12-22-2005 10:48 PM
Re: Help Needed for Script
Now my script is working fine and once again thanks to all guys.
Happy Christmas and New YEAR