- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- difference between sh and ./
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2008 08:29 PM
тАО04-24-2008 08:29 PM
difference between sh and ./
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
- Tags:
- PATH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2008 08:39 PM
тАО04-24-2008 08:39 PM
Re: difference between sh and ./
Typically root doesn't put "." in its $PATH as a security precaution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2008 09:07 PM
тАО04-24-2008 09:07 PM
Re: difference between sh and ./
As Dennis mentioned it above, it is a PATH issue.
You can run a script by specifying either of the following:
1. Relative path
e.g.
./abc.sh
2. Full path
e,g,
/home/yogeeraj/abc.sh
3. Specify the location of the script in the PATH environment variable.
e.g.
export PATH=$PATH:/home/yogeeraj/
or
export PATH=$PATH:.
then you can just:
abc.sh
Also, as mentioned root have "." in its $PATH as a security precaution.
hope it is now clear.
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2008 09:47 PM
тАО04-24-2008 09:47 PM
Re: difference between sh and ./
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
#ksh abc.sh
you are trying to execute the script using POSIX shell and you write the script using korn shell. you have mistaken buddy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2008 02:42 AM
тАО04-25-2008 02:42 AM
Re: difference between sh and ./
Since they are pretty similar, it still may work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2008 05:54 AM
тАО04-25-2008 05:54 AM
Re: difference between sh and ./
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.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2008 05:48 PM
тАО04-25-2008 05:48 PM