0

So I'm trying to run a python with this syntax that i found in internet.

python test.py test&

I'm wondering what does the test& mean?.

When i just run python test.py and ps aux | grep python the output is.

root    19858  0.0  0.3  15148  6164 pts/1    S    23:07   0:00 python test.py

And when you run python test.py test& The output now in ps aux | grep python is

root    19858  0.0  0.3  15148  6164 pts/1    S    23:07   0:00 python test.py test

I know the last part starting from python is command but can you explain further.

DennisLi
  • 3,915
  • 6
  • 30
  • 66
Nikko Bobier
  • 100
  • 11
  • 3
    `test&` is actually two things: `test` and `&`. The `test` potion is an argument to your python script, available in `sys.argv`. The `&` part is something most Unix shells will treat as an indication to run the process in background. – Tom Karzes Jul 11 '19 at 06:13
  • oh so it's not like an alias for a running process? – Nikko Bobier Jul 11 '19 at 06:17
  • @NikkoBobier : See [here](https://books.google.de/books?id=7ExfDfcLZXsC&lpg=PA547&ots=4RbavLVnFS&dq=shell%20separate%20commands&pg=PA547#v=onepage&q=shell%20separate%20commands&f=false) for the shell syntax. – user1934428 Jul 11 '19 at 09:52

2 Answers2

1

See the following: What does "&" at the end of a linux command mean?

It means its running in the background.

Paul
  • 110
  • 9
1

As long as you write command in a shell each word is take as a parameter

  • parameter 0 : python means that you use the python command
  • parameter 1 : test.py the first parameter given to the command parameter so in your script you cant get the string test.py by using sys.argv[0]
  • parameter 2 : test the second parameter given to the command parameter so in your script you cant get the string test by using sys.argv[1]

The & symbol is a bash character which mean run in background the previous command so your script will run but you still get an access on your terminal.

Xiidref
  • 1,456
  • 8
  • 20
  • 1
    The & originated with the Unix Bourne Shell, sh. It was later adopted by csh. bash is a descendant of sh which extended the syntax and added some csh-like features. Another sh descendant is ksh. There are csh descendants as well, such as tcsh. OP may be using any one of these. OP may be using `bash`, or may be using any one of the other shells I listed above. – Tom Karzes Jul 11 '19 at 07:19
  • OP tagges the post as _shell_, which, without any other shell-related tag, is supposed to mean POSIX shell. – user1934428 Jul 11 '19 at 09:49