Operating System - HP-UX
1833847 Members
2354 Online
110063 Solutions
New Discussion

Re: creating custom shell commands

 
SOLVED
Go to solution
nagendra_3
Advisor

creating custom shell commands

Hi,
I have created some shortcuts like
docs=`cd /web-root/web/jsp; pwd;` and placed in my .profile file.

Expecting if i type in docs, i will get changed to the directory desired,

Insted i get the following error
"sh: docs: not found"

Can any one help me.

Thanx,
Nag
Knowledge is Power
3 REPLIES 3
T G Manikandan
Honored Contributor

Re: creating custom shell commands

For csh you can use alias

alias docs `ls /web-root/web/jsp`

For ksh/sh

$docs()
>ls /web-root/web/jsp
$alias docs='docs'
Rajeev  Shukla
Honored Contributor
Solution

Re: creating custom shell commands

Hi,
The best for you is to use "alias" command
use this in the .profile
alias docs="cd /web-root/web/jsp; pwd"

now if you type
docs it will run the command.

Cheers
Rajeev
Mark Grant
Honored Contributor

Re: creating custom shell commands

In the standard posix shell you can also use an alias as in

alias "myls=ls -l"

If you put these in your .profile they will be there every time you log in.

THe reason your commands are not being found is because the directory in which you put them is not specified in the PATH variable. The system looks throught his variable to find commands you type. You can look at this variable with "echo $PATH".

You have two choices, you can use the full path to your command when you run them like "/home/me/docs" or you can create a directory called scripts in your home directory and in your .profile do something like "export PATH=$PATH:/home/me/scripts". Put your scripts in this directory and everything should work.
Never preceed any demonstration with anything more predictive than "watch this"