0

I have to follow instructions for a Java project but know nothing about Terminal.

I basically created what seems to be a path by typing cd /'path' which leads to a folder. In this folder is located a file I need to execute a bash command on bash updatemcp.sh.

The file only contains:

#!/bin/bash ./runtime/updatemcp.py "$@"

When I run it with the dot at the beginning of the path it outputs this: env: python2: No such file or directory

However whenever I execute the command without the dot at the beginning of the second line of the file it outputs this: updatemcp.sh: line 2: /runtime/updatemcp.py: No such file or directory when I'm 100% sure there is a file called updatemcp.py here...

The runtime folder is in the folder is contained in the dc 'path' folder

Thanks in advance

Miloertas
  • 320
  • 1
  • 3
  • 10
  • Install Python v2.x – that other guy May 11 '18 at 21:13
  • Hi. I would suggest you'll first make yourself familiar with the terminal a little https://code.tutsplus.com/tutorials/command-line-basics-and-useful-tricks-with-the-terminal--cms-29356 Regarding your script, it looks like python (specifically python2) is required for your script but not installed (http://docs.python-guide.org/en/latest/starting/install/osx/) – Capricorn May 11 '18 at 21:14
  • `env: python2: No such file or directory` means `updatemcp.py` starts with `#!/usr/bin/env python2`. That means that an executable named `python2` needs to be present in your PATH, ie. that `which python2` or `type -P python2` be able to find the location of same. – Charles Duffy May 11 '18 at 21:19
  • BTW, unrelated to your problem, but it would be ever so slightly more efficient to change the 2nd line to `exec ./runtime/updatemcp.py "$@"` -- that tells the shell script it can stop executing immediately and let the program it's invoking take over its process table entry. Of course, you can only do this safely when it's the very last command your shell script is expected to execute. – Charles Duffy May 11 '18 at 21:22
  • @thatotherguy I do have it as when I type `python` in Terminal it outputs the version – Miloertas May 12 '18 at 06:33
  • @CharlesDuffy I didn't quite get your answer, which parts of the files do I need to edit then? – Miloertas May 12 '18 at 06:36
  • 1
    @Miloertas, but you aren't trying to run `python`, you're trying to run `python2`. What does it do when you type `python2` into the Terminal? If it says it's not found, (1) there's your problem; (2) you can fix it by either *creating* a `python2` link in the PATH (like the flagged duplicate tells you to), or by fixing the shebang that's the first line of `updatemcp.py` to refer to the Python executable under a name it's actually installed with. – Charles Duffy May 12 '18 at 16:43
  • @CharlesDuffy I think that's the issue, Though I didn't quite understood what I needed to do in order to fix that problem – Miloertas May 22 '18 at 11:07
  • 1
    Easy answer: Open your script in a text editor, and change `python2` in the very first line to `python`. – Charles Duffy May 22 '18 at 15:30
  • @CharlesDuffy Yes, but the first line of my file is #!/bin/bash and not python – Miloertas May 22 '18 at 16:57
  • Open the *Python* script (`updatemcp.py`) and change that line. – Charles Duffy May 22 '18 at 16:58
  • It's a shell script, and when I do that it won't work, I don't want to waste your time really I do feel like my case is hopeless – Miloertas May 22 '18 at 17:03
  • `updatemcp.py` (not `.sh`, but the `.py` file it calls) is a shell script? It's a rather grossly misnamed one, if so. – Charles Duffy May 23 '18 at 15:03
  • ...anyhow, a fallback approach is to change `./runtime/updatemcp.py "$@"` to `python ./runtime/updatemcp.py "$@"` – Charles Duffy May 23 '18 at 15:04

0 Answers0