Need to execute the script with script name wihtout using ./scriptname in Solaris 10

Hi,
I am using solaris 10.Is there any way to execute the script with the scriptname wihtoug using ./scriptname?Also does it varies from shell to shell.I have scripts in bash,ksh,sh shells.

 
Example:script.sh is the script name.I need to execute the script like this script.sh instead of ./script.sh.Does it varies from shell to shell?

Advance thanks for your reply.

make the file script.sh executable by changing its file permissions.
Use following command for this.

chmod 777 script.sh

Then you can execute it by

sh script.sh

Some use full info for you to take a decision

You have several choices:

  • Use an absolute path like /home/mydir/script.sh command.

  • Put the script in a directory that is part of your PATH, which you can check with echo $PATH and set in your $HOME/.profile config file. You could have a $HOME/bin directory and put your scripts there, and include it in your PATH.

  • It's possible the "current directory" is in your path (not the safest thing), in which case you can just execute the command by typing "script.sh" if you are in the same directory as the script.

The first step (making the script executable) is actually not required when you use that method ( sh file ) to launch the script. Moreover, chmod 777 pose a security risk, use chmod +x instead.