Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-17-2010, 12:05 AM   #1
Registered: Sep 2009
Posts: 84

Rep: Reputation: 15
Post are they same " sh execution " and " ./ execution "

hi ,

i created a script file named

i ran this by typing sh and i got my output


when i tried to execute by typing ./ i received permission denied error
i gave permission as chmod 777
then i executed by typing ./ . It worked fine

so i wanted to know whether using sh and ./ with permissions are same.. ?

or did it work for only this.. are there any differences ???


Last edited by shravee; 04-17-2010 at 12:07 AM.
Old 04-17-2010, 01:11 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
I think sh starts a sh shell which then runs the script (so two processes) whereas ./ runs the script in a subprocess (so one process). You can find out by putting a sleep in your script (so it "runs" for a long enough for you to ...) use pstree to see the process tree. Another difference is that sh runs the script using the sh shell whereas ./ runs the script respecting any #!<interpreter path> on the first line of your script. Even if sh (/bin/sh?) is a symbolic link to bash (/bin/bash?) bash behaves differently depending on the name it is called by.

If you want to run your script simply by then you need to add "." (without the quotes) to your $PATH.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execution of a script to be stopped after "x" minutes of time YSE Linux - Newbie 3 10-01-2008 12:00 AM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 07:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Lost Execution rights of "chmod" arkus Linux - General 2 10-05-2004 09:58 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration