LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Difference between ./ and & to run a script (https://www.linuxquestions.org/questions/linux-newbie-8/difference-between-and-and-to-run-a-script-943556/)

AffanLinux 05-06-2012 02:02 PM

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!

TobiSGD 05-06-2012 02:04 PM

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.

grail 05-06-2012 02:06 PM

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

chrism01 05-07-2012 07:14 PM

What they said ^ :)
Also, if you are researching this, you should also lookup the nohup cmd .. ;)

Soadyheid 05-08-2012 05:46 AM

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! :hattip:


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