Need to disable options from a command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to disable options from a command
# 1  
Old 04-11-2011
Need to disable options from a command

Hi,

I am working on a Linux machine.
I need to disable 2 options from the available 6 options of a command.
For eg. in the "ls" command we have various options like "l ,r, t, a, .... "
From this, I need to disable option "a"

So when the users type in "ls -a", they should get an error or option not available. However when the type "ls -l", they should be able to see the long listing normally.

Is this possible? I don't have root access but can work with the Linux admins to disable the world execute permission on the command and have a script or something similar to enable only the required options.

Any help will be appreciated.
# 2  
Old 04-11-2011
For starters, you would probably want to create an alias for the original command, which in turn would point to a function that could evaluate the parameter options/choices to produce the exclusive error you are looking for.
# 3  
Old 04-11-2011
Quote:
Originally Posted by aster007
[SIZE=2][FONT=Tahoma]Hi,

I am working on a Linux machine.
I need to disable 2 options from the available 6 options of a command.
For eg. in the "ls" command we have various options like "l ,r, t, a, .... "
From this, I need to disable option "a"
For what purpose? Not showing them their config files won't prevent them from having access every other way, such as finding them with find, matching them with shell globbing, finding them with tab completion, etc, etc, etc. The forced hiding could also be abused: Users could create files starting with . and nobody would find them.

What is your actual goal?
# 4  
Old 04-11-2011
@Corona688 - I am not going to disable the options for "ls" command. I am just using this one as an example. I need to do it for some other command where a particular application server is being stopped by using a command which also has options to list down other some details which the users still might want to use.
# 5  
Old 04-11-2011
in /etc/profile or the .profile of some selected users:
Code:
alias somecmd='/path/to/myscript'

Code:
#!/bin/ksh
# myscript: dummy wrapper for somecmd
#  disallow -l
echo "$@" grep -q  '-l'
if [ $? -eq 0 ]  ; then
   echo 'illegal option'
   exit 1;
fi
/full/path/to/somecmd "$@"

This is bare bones, you need to work it up to what you need. One fault: if the user knows that /full/path/to/somecmd works he/she might use it that way - it will bypass the alias.
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ls command options

Hi, If I want to list files with names containing a certain letter like " a " using just one ls command, is there any way of doing that? Note that it is containing a letter instead of one of the following (starting, ending with a letter or having the letter in between). what I want is to show... (1 Reply)
Discussion started by: AAAnni
1 Replies

2. AIX

Disable a command

I need to disable a command. For example - disabling "ls" means that when someone type "ls" - nothing happens . Somebody help ???? :confused::confused::confused: (8 Replies)
Discussion started by: bobochacha29
8 Replies

3. Shell Programming and Scripting

Help executing command with options

Hi, I have this command in a shell script and I can get it to echo ok, but when I try to execute the command I get a "file not found" error. Which is strange because, if I copy and paste the same command at the cli it works ok. What am I doing wrong please? (16 Replies)
Discussion started by: bbbngowc
16 Replies

4. Shell Programming and Scripting

Reading command options one by one

Hi, Just some questions on the script below...? Given: bash-2.03$ command -a option1 name1 name2 ParseOptions() { local Len=${#@} local Ctr=2 #always start at 2 local Name=() local Iter=0 while ; do if <- Is this correct? so I can get the $2... (2 Replies)
Discussion started by: h0ujun
2 Replies

5. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

6. Red Hat

How can i disable force options for linux commands

Sir , Is there any way for me to disable force (-f ) options to linux commands like rm. I tried to alias rm -f. alias rm -f = "rm -i" but it shows bad alias name error I need this command specifically for rm. Atleast i want this command to be interactive whether I issue rm ,rm... (2 Replies)
Discussion started by: iamjayanth
2 Replies

7. HP-UX

Linux - HP UX Command options

Just I gone with the script, I found some command's options which are not compatible with " HP-UX ". If I found any alternate commands to the following, most probably I will solve the issue here. 1. " iostat -x " --> this command's option( x ) is not available in HP-UX... (2 Replies)
Discussion started by: pk_eee
2 Replies

8. Shell Programming and Scripting

how to? launch command with string of command line options

my description from another thread... here's my code: #!/bin/bash IFS=$'\n' function OutputName() { input=$1 echo $input input=`echo "$input" | sed -e 's/.//'` input=`echo "$input".avi` output_name=$input } if ]; then echo... (5 Replies)
Discussion started by: TinCanFury
5 Replies

9. UNIX for Advanced & Expert Users

Split Command options

HI! All iam using Split command to split a large .txt file in to smaller files, The syntax iam using split -25000 Product.txt iam getting four output files but not in .txt format but in some other format , when i checked the properties the Type of the output files is Type can any... (7 Replies)
Discussion started by: mohdtausifsh
7 Replies

10. UNIX for Advanced & Expert Users

Disable the `rm -f ` command

I wish to learn how to use the alias command in .cshrc I need to change some Unix commands, like : change "rm -f " into "rm -i " or to write small scripts using alias. (7 Replies)
Discussion started by: kamil
7 Replies
Login or Register to Ask a Question