cancel
Showing results for 
Search instead for 
Did you mean: 

shortcut to run a script

Renney
Occasional Contributor

shortcut to run a script

Hi,
I am a new user to use HP-UX 11.11.
I want to ask got any shortcut to run a script instead of typed "sh" or "./" in front of the script name to run it ?
Thanks.
5 REPLIES
SKR_1
Trusted Contributor

Re: shortcut to run a script

This is the only way to run the script.
I think this is already a shortcut to run a script.

Thanks

SKR
Steven Schweda
Honored Contributor

Re: shortcut to run a script

Use chmod to make it executable. Details
depend on exactly what you want, but:

chmod a+x script_name

Then move (or copy) the script into a
directory on your PATH (or add its current
directory to your PATH). Details depend on
your shell, but perhaps something like:

mkdir ~/bin
cp script_name ~/bin
PATH="${PATH}:~/bin"

Then (depending on what's in the script):

script_name

should run the thing.

You could add "." to your PATH (instead of
"~/bin"), but that makes it easy to find
yourself running some local garbage instead
of the script you expected to be running.
Steven Schweda
Honored Contributor

Re: shortcut to run a script

> This is the only way to run the script.

It's almost never correct to say "only way".
Wouter Jagers
Honored Contributor

Re: shortcut to run a script

You could also check out aliases.

You can define an alias which is substituted with anything you want, including long and complex command lines. This way, you can reduce your frequently used commands to just a few characters, if you want.

Check out http://docs.hp.com/en/B2355-90046/ch18s02.html?btnPrev=%AB%A0prev

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
James R. Ferguson
Acclaimed Contributor

Re: shortcut to run a script

Hi:

Prepending "./" says 'find this file in my current directory'.

If you aren't the 'root' user, the '.' [current directory] is included in your PATH as the last choice. Hence, there is no need to specify anything but your execuatable's name.

Do *NOT* add '.' to root's PATH. This is a hugh security hole. You want to be sure you know what you are running and you don't want to easily and capraciously execute something you don't want to run merely because you typed (or mistyped) a command.

Regards!

...JRF...