The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
option followed by : taking next option if argument missing with getopts gurukottur Shell Programming and Scripting 2 03-17-2008 08:46 AM
Disable GUI HP-UX mdjuarsa HP-UX 1 10-06-2007 04:51 AM
How to disable SU right civic2005 SUN Solaris 3 03-09-2007 09:16 AM
disable su sak900354 UNIX for Dummies Questions & Answers 2 06-15-2006 12:56 AM
Disable TCP-OPTION fields null255 UNIX for Advanced & Expert Users 2 10-07-2005 03:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-20-2005
Registered User
 

Join Date: Feb 2005
Posts: 2
Stumble this Post!
KSH : Disable -x option

I have a KSH script. I want NO-ONE to call it with -x option.

example : ksh -x /appl/u001/test_it_out.ksh

Is there a way to know, from with in script, that they invoked the script with -x option. So that I can exit when they invoke it with -x option.

please help.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-20-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Stumble this Post!
Yes....

Code:
$ cat vangaru.ksh
#! /bin/ksh

case $- in
  *x*) echo "Invoked with -x" && exit 1
         ;;
esac

echo "Is okay...."

exit 0
$ ksh ./vangaru.ksh
Is okay....
$ ksh -x ./vangaru.ksh
+ echo Invoked with -x
Invoked with -x
+ exit 1
Cheers
ZB
Reply With Quote
  #3 (permalink)  
Old 10-20-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,424
Stumble this Post!
Or you could use "set +x" as your first statement. Bear in mind that anyone who can execute the script can read it. So they can copy it and remove this code, then run the copy.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0