System Is Returning Error 127 When Called from C++ in Linux

127 Return code from $?

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

PHP System return 127 error code

/bin/sh could not be executed, the exit status will be that of a command that does exit(127).I advice you run your PHP program as root user.

running .exe from R: status 127 warning on Linux not on Windows

The problem actually stemmed from the fact that .exe files are executables for Windows only. It does not work out of the box on Linux environments (you can use WINE but in my case it is not possible because I am calling the executable from within R, I don't have any sudo rights or anything on the virtual machine used by the host of my app). So I compiled the c++ code I had using g++ on a Linux virtual machine and used the .out file rather than the .exe.

Then in my R script I just needed these two calls:

system("chmod a+x script.out") # to make Linux understand that the file is an executable
system("./script.out object") # to run the script

R system functions always returns error 127

As I mentioned in my comments, the R documentation reveals that in Windows the system() function does not launch a separate shell (if needed). This is why command line commands run with system(), but Notepad, which needs a separate window, does not run:

From the documentation for system():

The most important difference is that on a Unix-alike system launches a shell which then runs command. On Windows the command is run directly – use shell for an interface which runs command via a shell (by default the Windows shell cmd.exe, which has many differences from a POSIX shell).

Make Error 127 when running trying to compile code

Error 127 means one of two things:

  1. file not found: the path you're using is incorrect. double check that the program is actually in your $PATH, or in this case, the relative path is correct -- remember that the current working directory for a random terminal might not be the same for the IDE you're using. it might be better to just use an absolute path instead.
  2. ldso is not found: you're using a pre-compiled binary and it wants an interpreter that isn't on your system. maybe you're using an x86_64 (64-bit) distro, but the prebuilt is for x86 (32-bit). you can determine whether this is the answer by opening a terminal and attempting to execute it directly. or by running file -L on /bin/sh (to get your default/native format) and on the compiler itself (to see what format it is).

if the problem is (2), then you can solve it in a few diff ways:

  1. get a better binary. talk to the vendor that gave you the toolchain and ask them for one that doesn't suck.
  2. see if your distro can install the multilib set of files. most x86_64 64-bit distros allow you to install x86 32-bit libraries in parallel.
  3. build your own cross-compiler using something like crosstool-ng.
  4. you could switch between an x86_64 & x86 install, but that seems a bit drastic ;).

Why do I get a system status error of 127 when I run wget in R?

You're using Windows. wget is a Unix/Linux program. You can just call download.file to download from within R:

download.file("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/2016/999999-54856-2016.gz",
"999999-54856-2016.gz", mode="wb")

The mode="wb" is important for downloading binary files on Windows.

Exec command returns 127 error code

The problem is that the maximum length of a command line is 65535 bytes. I don't know why your command line test worked, maybe you've tried it with short filenames but one full command cannot exceed this limit.

The reason I found your question is because I was calling a command line with a heredoc as standard input, and well, the length of a heredoc can easily run away so I rewrote the call using popen() but that doesn't help you. I haven't worked with the zip utility yet, but a quick look at it's manpage says it appends files to existing archives so you should be able to split your command lines after every 64k if you want max efficiency, or after every 100 or even every single file if you want a simple algorithm.



Related Topics



Leave a reply



Submit