Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-09-2010, 07:46 PM
|
#1
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Rep:
|
shell script fails to exit
This is a very simple problem, but i'm scratching my head with others..
In composing a simple shell script in class, we can't seem to get the script to execute fully. script was formatted as follows.
#!/bin/bash
echo "good bye for now"
exit
did, Chmod 755 to make executable
type file name "bye"
runs but wont exit.....
it just echos the type"good bye for now
The instructor says it works for him at home....
But it wont work in class...
Is there a reason it wont "exit" the shell as commanded ?????
we are using putty with bash shell Linux.
Last edited by twrig3846; 02-09-2010 at 08:27 PM.
Reason: wrong chmod code
|
|
|
02-09-2010, 08:23 PM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
What do you mean by "doesn't exit"? You don't get to a shell prompt,
it just sits there as if in a loop??
|
|
|
02-09-2010, 11:10 PM
|
#3
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Works for me.
Code:
c:~$ echo '#!/bin/bash
> echo "good bye for now"
> exit' > /tmp/bye.sh
c:~$ chmod +x /tmp/bye.sh
c:~$ /tmp/bye.sh
good bye for now
c:~$
What are you doing different?
|
|
|
02-09-2010, 11:27 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Hmmm ... maybe he expects the 'exit' in the script
to do what it would do on the shell - terminate the
session, close his putty connection?
|
|
|
02-09-2010, 11:32 PM
|
#5
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Original Poster
Rep:
|
wont exit
Yes it appears to echo good bye and returns to the shell prompt, the
instructor leads me to believe that this script should run and leave you
exiting the Linux program and exits back to windows, I seem to be missing
something somewhere...
When I type in the filename which is "bye" He says this should leave the Linux completely after saying "goodbye" or rather typing it.and cause you to exit as if you typed "exit" and hit enter.
|
|
|
02-09-2010, 11:38 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Well ask him where he got that idea from.
An exit in a script will only terminate the SUB-shell that
you invoked when starting the script.
|
|
|
02-09-2010, 11:51 PM
|
#7
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
Works for me.
Code:
c:~$ echo '#!/bin/bash
> echo "good bye for now"
> exit' > /tmp/bye.sh
c:~$ chmod +x /tmp/bye.sh
c:~$ /tmp/bye.sh
good bye for now
c:~$
What are you doing different?
|
I don't seem to be doing anything different, Maybe he is just testing us.
his statement was "does it work or not" if not why? and if so why?
maybe I'm chasing my tail, I know the exit command works if I'm not in the directory he tells us to be in so maybe that's my clue.
He starts us out by making a directory named bin in our home directory and in this directory to make a file named bye and to make this file executable and run this bye script.......this is where I'm at....????
|
|
|
02-09-2010, 11:53 PM
|
#8
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
Well ask him where he got that idea from.
An exit in a script will only terminate the SUB-shell that
you invoked when starting the script.
|
You know I was just discussing this with my wife and thought of the exact same thing....I think he is testing me..The Instructor that is..
|
|
|
02-09-2010, 11:53 PM
|
#9
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by twrig3846
I don't seem to be doing anything different, Maybe he is just testing us.
his statement was "does it work or not" if not why? and if so why?
|
There's your answer.
Evo2.
|
|
|
02-09-2010, 11:59 PM
|
#10
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Original Poster
Rep:
|
I know I'm still a newbie and am learning all the time..Thanks to all who helped me out tonight, You have been a great help..I thought all along that this was the case but was expected to find my own answer.. The KW book and the SKS are very vague in some explanations...Thank You
|
|
|
02-10-2010, 12:01 AM
|
#11
|
LQ Newbie
Registered: Jan 2010
Posts: 7
Original Poster
Rep:
|
Quote:
Originally Posted by evo2
There's your answer.
Evo2.
|
Thanks I thought so all along but wasn't sure...
|
|
|
All times are GMT -5. The time now is 12:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|