defining our own shell commands
hello friends..
i am working on red hat linux (kernal 2.6). Although it has a GUI to work upon but still i wish to work on its shell and be perfect in that too. Can anybody tell how to create our own shell commands. i mean that supposedly if some one has to access the cdrom and he does not remember all those shell commands to mount the cd-rom and all that, then i define a command in such a way that it contains all those things required to access the cdrom and the other person just writes the command and he can access the cdrom well.. Hope you people are able to understand my problem.. Please help me out if possible. |
Hi ashley_31
To do do you have to create alise. |
if u wanted to help me, u cud have done it in a better way..
i was doing that blabla bacause i didnt have an idea of how to solve my problem. how do i create this alise?? |
Hi
Sorry i didn't got time to write more than this on the previous post so here is an exemple: Code:
alias hiden="ls -al" You can do the same thing with mount Code:
alias mountcd="mount -t iso9660 -o ro /dev/cdrom /cdrom" Does it helpfull enought? ask tell me if you need more help. Regards, Angel. |
Is it better to use this alias command or should i make a shell program for this.??
|
Depends how involved you want it to be, if its just 1 command for a static drive/mount point run by a user or 2 (alias in their profile, or could be in global profile). Then i would go for an alias as above, if you have different drives/ mount points, i'd make a shell script with user inputted variables. You would also be able to set permissions for your script.
|
For bash script:
here it is if you want to create a script: 1. Create a text file named "mountcd" 2. Edit it with a text editor and put the following inside: Code:
#!/bin/bash Code:
$chmod 555 /Path_of_your_script/your_script Code:
$su enjoy your new command. For the alias: 1. edit the file .bashrc in your home folder and add your alias line at the end. 2. Save the change, logout and log back in enjoy your new command. |
Quote:
Code:
source ~/.bashrc Either way alias or shell script suggested by angel115 will both work just fine ashley_31. Try out both methods and see which one you like best. Good luck! |
Please do not post threads on the same topic more than once. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.
http://www.linuxquestions.org/rules.php http://www.linuxquestions.org/questi...d.php?t=443372 |
All times are GMT -5. The time now is 08:40 AM. |