LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-08-2006, 02:24 PM   #1
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Alias or shell script to confirm 'exit' commands from a shell


I use PuTTy to connect to multiple servers at work, and am usually jumping between various su <user> layers all day. Therefore, typing 'exit' to get back down to the user I need to be next is pretty frequent.
However, sometimes I actually am just logged on as myself, and habitually type 'exit' instead of 'cd' or something like that. Is there a way to write a shell script called 'exit.sh' which would prompt me with "Sure you want to exit? [Y/N]" and if I type 'Y' would actually exit the window ...'N' would just exit the script?
 
Old 03-08-2006, 02:29 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
alias exit='dialog --yesno really\ exit? 5 20; [ $? == 0 ] && exit'
 
Old 03-08-2006, 02:34 PM   #3
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
I have no idea what that is or why it works, but it does, and therefore you are AWESOME

Thank you!
 
  


Reply

Tags
scripting, shell



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Commands shandy^^^ Programming 16 02-09-2006 10:16 AM
alias does not work in shell script mannahazarika Programming 9 01-20-2006 01:56 PM
Commands/Shell script ?? paraiso Linux - Newbie 11 04-21-2005 10:58 AM
Commands from shell script not working Grassie Coetzee Linux - Software 2 03-13-2005 02:31 PM
Delay in shell script or alias jeopardyracing Linux - Newbie 6 09-21-2004 08:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration