04-24-2008 08:29 PM
i login as root,and use sh abc.sh,it doesnot execute and returns no result.
when i use ./abc.sh,it can be correctly executed .
what is the difference between sh and ./, and why this happen
04-24-2008 08:39 PM
Typically root doesn't put "." in its $PATH as a security precaution.
04-24-2008 09:07 PM
As Dennis mentioned it above, it is a PATH issue.
You can run a script by specifying either of the following:
1. Relative path
2. Full path
3. Specify the location of the script in the PATH environment variable.
then you can just:
Also, as mentioned root have "." in its $PATH as a security precaution.
hope it is now clear.
04-24-2008 09:47 PM
If you run a script using sh , it means you did not mention the which shell the script will use. such as if you mention in the script #!/usr/bin/ksh, you can execute the script using ./abc.sh way. Moreover if the file permissions will not 777 , but with ksh abc.sh will work
>>i login as root,and use sh abc.sh,it doesnot execute and returns no result.
try to run like this
you are trying to execute the script using POSIX shell and you write the script using korn shell. you have mistaken buddy.
04-25-2008 02:42 AM
Since they are pretty similar, it still may work.
04-25-2008 05:54 AM
As noted, on a properly configured system, root's '.profile' does not specify a dot ('.') in the PATH variable it exports to its environment. This means that to specify a search within your current directory, *you* may need to type "./" in front of a file name.
To add a dot to root's PATH is a security risk.
By the way, setting 777 (rwx) permissions on your scripts is very poor security too! There is NO need for your group, and certainly not the world's community, to be able to *write* to your script! A setting of 755 is as far as you should go.