LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-06-2012, 03:02 PM   #1
AffanLinux
LQ Newbie
 
Registered: May 2012
Posts: 1

Rep: Reputation: Disabled
Difference between ./ and & to run a script


Hi, i installed vmware tools on my mint OS. i noticed i could run vmware-toolbox with either ./vmware-toolbox and vmware-toobox &

Is there any difference between these two?

Thanks!
 
Old 05-06-2012, 03:04 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Those two are totally unrelated. ./ before a script name tells your shell to look into the current directory, which is on Linux systems (opposite to Windows) not in the PATH. The ampersand (&) tells the shell to run a program in the background. Both commands have totally different uses and are not related.
 
Old 05-06-2012, 03:06 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
Well apart from ./ means your running the one in the current directory and without it you are running the one in your PATH, which may or may not include the current directory, and the & is telling the
shell to run the command in the background ... I would have to say ./ and & have very little in common
 
1 members found this post helpful.
Old 05-07-2012, 08:14 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
What they said ^
Also, if you are researching this, you should also lookup the nohup cmd ..
 
Old 05-08-2012, 06:46 AM   #5
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 17.0 at present.
Posts: 1,168

Rep: Reputation: 201Reputation: 201Reputation: 201
Welcome to Linux Questions!

The most noticeable thing you will find regarding the two ways of running the command is that
Code:
./<executable file>
will run the command within your terminal window and you can't use the terminal till it's complete and control is passed back to the terminal (The prompt re-appears) Yes, the executable file must be within your current directory.

Code:
 <executable file> &
will display the PID of the process the command started in the background but you are still able to work with the same terminal.

I thought you might like a slightly less-technical reply.

Play Bonny!
 
  


Reply


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
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 05:26 AM
review postgres dump script and difference between pg_dump & pg_dumpall noir911 Linux - Server 1 10-09-2008 11:11 AM
difference between shell script & make subbusp2 Linux - Newbie 1 07-23-2008 10:33 PM
Howto Encrypt & Run Bash script File nabeeliumattack Linux - General 7 05-17-2008 05:58 PM
Difference between executing & sourcing a script muazfarooqaslam Linux - Newbie 1 01-04-2008 03:51 AM


All times are GMT -5. The time now is 07:58 AM.

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