how to write shell specific commands?


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat how to write shell specific commands?
# 1  
Old 01-06-2009
Bug how to write shell specific commands?

I am using Fedora 8,Red hat 9.
Whenever we write a new command. Then we goto "/usr/bin" and then place this in this directory.And hence we can use it as a command anywhere from the terminal.
We generally see commands like "trap" which run only in bash shell.We also have other shell specific commands which are limited to one shell alone...I wanted to know how is bash able to do it.How can we make a command work in one shell but not in the other ???
# 2  
Old 01-06-2009
Quote:
Whenever we write a new command. Then we goto "/usr/bin" and then place this in this directory.And hence we can use it as a command anywhere from the terminal.
That is not a good idea, at all, for a variety of reasons. bash is already extensible - meaning you can write code to do special roll-your-own-commands, and then have bash include the command.

If you absolutely have to 'add commands' the way you are doing it, put the command scripts in /usr/local/bin or maybe /opt/local/bin/<some name>. The directory cannot be world write nor can any script be writable by anybody but root -- or you create giant security hole.

Now you can change the PATH variable at run time. If the PATH has ":/usr/local/bin" in it then you execute one of your special commands. If the PATH does not have it, then the special command will not be found. Simply change the PATH at runtime.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I write the specific content in the file through shell script

Hello, I need to do one thing that my script creates the file touch release.SPLASH_12_03_00_RC01.txt Now I want to update that file with some content e.g splashbuild::SPLASH_12_17_00_RC02.zip Thanks (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

2. Linux

Suggest update of two commands - who to write to?

I think it's about time the df and du commands (executables?) were updated to display gigabyte units without one having to do their own calculations from the -m option (display in megabytes). This is one of those "little nothing" annoyances that, at the same time, would positively show new... (3 Replies)
Discussion started by: SilversleevesX
3 Replies

3. Shell Programming and Scripting

How can i write a script to execute commands on the webserver from a browser?

I want to create a script with the php exec() or system() function to execute commands from a remote browser on the webserver. I am open to using Perl or whatever. I am using an Apache2 webserver on Ubuntu. I have done quite a bit of research on this on google and read lots of responses about... (0 Replies)
Discussion started by: bash_in_my_head
0 Replies

4. Homework & Coursework Questions

Can anyone help? I have to Write a program in C that recognizes the following commands and translate

I have to Write a program in C that recognizes the following commands and translates them into much simpler ones Commands to recognize shorter command list L cd dir C - dir_length - dir get file_name G - file_name_length - file_name Long commands are read from the standard input... (1 Reply)
Discussion started by: aintour
1 Replies

5. UNIX for Dummies Questions & Answers

Can anyone help? I have to Write a program in C that recognizes the following commands and translate

I have to Write a program in C that recognizes the following commands and translates them into much simpler ones Commands to recognize shorter command list L cd dir C - dir_length - dir get file_name G - file_name_length - file_name Long commands are read from the standard input and... (1 Reply)
Discussion started by: aintour
1 Replies

6. UNIX for Dummies Questions & Answers

How to use a Shell Script for specific commands

I have a set of commands that I am using to copy specific areas of source code in a Cold Fusion document and export the code into recreations of the original files into a sub-directory. Here are the 3 commands I am using: mkdir ./out && for x in *.cfm; do awk '{FS="<!-- InstanceBeginEditable... (17 Replies)
Discussion started by: dratech09
17 Replies

7. Fedora

wall and write commands are not working

hi friends i am using fedora linux operating system on the server and two clients(with windows os) are connected to it(server ).but here wall and write cmds are not working to send messages from one system to another system . pls help me (4 Replies)
Discussion started by: sankar_vitam
4 Replies

8. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

9. Shell Programming and Scripting

How to write a script by using unix commands to down any server

Hi, I need to do frequently server down and up. Every time i am using nearly 5 to 6 commands to down and agin i am using the commands to up. Can anybody help me to write a script to down and up. which i can use once on unix platform it can down later it can up the server. (1 Reply)
Discussion started by: sreerao
1 Replies

10. Shell Programming and Scripting

how can I write script that lets me run shell commands?

Hello I want to make simple extension to vi , you know how you want to run some shell command you do ":! ls -l " , then you go out the vi the command executed and then you hit enter and you back to vi but now I want to be able to go out of vi and run several command outside of vi .. and in... (3 Replies)
Discussion started by: umen
3 Replies
Login or Register to Ask a Question