i opened vi editor and wrote my first shell script and saved it as SS1.sh
#!/bin/bash #SS1 #Usage:SS1
ls
--came back onto console and tried the following
./SS1.sh
SS1.sh
Note: the shell script is stored on my D drive D:/scripts and the console on cygwin also points to the same folder D:/scripts
I tried echo $PATH and this is what i get
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/d/Perl/site/bin:/cygdrive/d/Perl/bin:/cygdrive/c/sybasenew1/DataAccess/ODBC/dll:/cygdrive/c/sybasenew1/RPL-15_0/bin:/cygdrive/c/sybasenew1/Shared/Sybase Central 4.3:/cygdrive/c/sybasenew1/UAF-2_0/bin:/cygdrive/c/sybasenew1/OCS-15_0/lib3p:/cygdrive/c/sybasenew1/OCS-15_0/dll:/cygdrive/c/sybasenew1/OCS-15_0/bin:/cygdrive/c/sybasenew1/ASE-15_0/dll:/cygdrive/c/sybasenew1/ASE-15_0/bin:/cygdrive/d/sybasenew1/DataAccess/ODBC/dll:/cygdrive/d/sybasenew1/RPL-15_0/bin:/cygdrive/d/sybasenew1/Shared/Sybase Central 4.3:/cygdrive/d/sybasenew1/UAF-2_0/bin:/cygdrive/d/sybasenew1/OCS-15_0/lib3p:/cygdrive/d/sybasenew1/OCS-15_0/dll:/cygdrive/d/sybasenew1/OCS-15_0/bin:/cygdrive/d/sybasenew1/ASE-15_0/dll:/cygdrive/d/sybasenew1/ASE-15_0/bin:/cygdrive/d/sybasenew/OCS-15_0/lib3p:/cygdrive/d/sybasenew/OCS-15_0/dll:/cygdrive/d/sybasenew/OCS-15_0/bin:/cygdrive/d/sybasenew/ASE-15_0/dll:/cygdrive/d/sybasenew/ASE-15_0/bin:/cygdrive/c/DataAccess/ODBC/dll:/cygdrive/c/RPL-15_0/bin:/cygdrive/c/Shared/Sybase Central 4.3:/cygdrive/c/UAF-2_0/bin:/cygdrive/c/OCS-15_0/lib3p:/cygdrive/c/OCS-15_0/dll:/cygdrive/c/OCS-15_0/bin:/cygdrive/c/ASE-15_0/dll:/cygdrive/c/ASE-15_0/bin:/cygdrive/c/DataAccess/ODBC/dll:/cygdrive/c/RPL-15_0/bin:/cygdrive/c/Shared/Sybase Central 4.3:/cygdrive/c/UAF-2_0/bin:/cygdrive/c/OCS-15_0/lib3p:/cygdrive/c/OCS-15_0/dll:/cygdrive/c/OCS-15_0/bin:/cygdrive/c/ASE-15_0/dll:/cygdrive/c/ASE-15_0/bin:/cygdrive/c/sybase/DataAccess/ODBC/dll:/cygdrive/c/sybase/RPL-15_0/bin:/cygdrive/c/sybase/Shared/Sybase Central 4.3:/cygdrive/c/sybase/UAF-2_0/bin:/cygdrive/c/sybase/OCS-15_0/lib3p:/cygdrive/c/sybase/OCS-15_0/dll:/cygdrive/c/sybase/OCS-15_0/bin:/cygdrive/c/sybase/ASE-15_0/dll:/cygdrive/c/sybase/ASE-15_0/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/sybase/DBISQL/bin:/cygdrive/c/DBISQL/bin:/cygdrive/c/DBISQL/bin:/cygdrive/d/sybasenew1/DBISQL/bin:/cygdrive/c/sybasenew1/DBISQL/bin:/cygdrive/c/Program Files/QuickTime/QTSystem/:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn/:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn/:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE/:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/IDE/PrivateAssemblies/:/cygdrive/c/WINDOWS/system32/WindowsPowerShell/v1.0
Your current directory can be referenced as . (dot)
That's why ./SS1 refers to SS1 in your current directory.
To avoid using ./SS1 and use just SS1, you need to add your current directory (.) to your path. PATH=.:$PATH adds . (your current directory) to your path.
It is highly recommended that you don't put (.) in your PATH for security reasons. Either call the script with the path, or put the script in a directory that is already on your path, or add a specific directory to your path and put the script there.
Hi Irishboy, provide an 'execute' permission to the file..
chmod 766 <filename>
This will give -rwxrw-rw- permission to the file. Now try running your script.