The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unable to exit from a shell script Sreejith_VK Shell Programming and Scripting 2 05-30-2008 03:29 AM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM
checking exit status of a shell script kdipankar Shell Programming and Scripting 2 05-09-2006 01:08 AM
exit shell script from function nvrh7 Shell Programming and Scripting 1 11-27-2005 11:28 AM
using exit command in a shell script jpprial UNIX for Dummies Questions & Answers 1 02-16-2001 12:45 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2007
sami98 sami98 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
exit a shell script!!

could somebody tell me please how to exit a shell script:

if [ $# -eq 0 ]
then
echo "No arguments detected"
exit 1
fi
...
echo "still there" # is displayed .. :-(
  #2 (permalink)  
Old 03-27-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
if [ $# -eq 0 ]
then
echo "No arguments detected"
exit 1 #exit shell script  
fi
...
echo "still there" # is displayed .. :-(
  #3 (permalink)  
Old 03-27-2007
sami98 sami98 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
sorry...... I have the following situation and it does not work :-( :

if [ $# -eq 0 ]
then
usage()
fi

echo "still there.."

usage {
echo "No arguments detected"
exit 1 #exit shell script
}
  #4 (permalink)  
Old 03-27-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
Try this..

Code:
function  usage {
echo "No arguments detected"
exit 1 #exit shell script
}
if [ $# -eq 0 ]
then
usage
fi

echo "still there.."
  #5 (permalink)  
Old 03-27-2007
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
Function must be declared before it is used in script.try the below script..
Code:
usage ()
{
echo "No arguments detected"
exit 1 #exit shell script
}

if [ $# -eq 0 ];
then
usage
fi

echo "still there.."
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0