Cannot run linux program

java.io.IOException: Cannot run program «/usr/bin/sh»: java.io.IOException: error=2, No such file or directory

As the exception says, there’s no file /usr/bin/sh on your system. If you’re looking for the Bourne shell, that’s /bin/sh .

public void run() < //log.info("taskDao:<>,concurrentHashSet:<>,id:<>,shellName:<>,shellDate:<>", taskDao, concurrentHashSet, id, shellName, shellDate); log.info("concurrentHashSet:<>,param:<>", concurrentHashSet, param); int exeState = 99999; // ssh跳转到其他机器去执行脚本,you can add "ssh rd@g1-jg-hadoop-01 \"source ~/.bash_profile ; bash -x %s %s\"" instead of command String command = "source ~/.bash_profile ; bash -x %s %s"; String commandF = String.format(command, param.getShellName(), param.getRecallDate()); String[] cmdArr = ; long taskId = param.getTaskId(); Runtime runtime = Runtime.getRuntime(); Process process = null; try < process = runtime.exec(cmdArr); InputStream stderr = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); String line = null; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) < sb.append(line).append(System.lineSeparator()); >log.info("exe task thread param:<>,commandF:<>,execute shell info:<>", param, commandF, sb.toString()); exeState = process.waitFor(); > catch (InterruptedException | IOException e) < log.error("execute shell error,exeState:<>,command:<>", exeState, commandF,e); > finally < log.info("execute shell state:<>", exeState); // 从set中删除 更新表状态 多张表一个脚本,会有问题,其中状态覆盖 if (exeState == 0) < // 执行成功 taskDao.updateStateByPrimaryKey(taskId, (short) 30, new Date()); // 邮件参数 param.setState(30); String mailBody = SendMailUtil.beautyMailHtmlLayout(param); String mailToAddress = param.getMailToUser(); String mailTitle = param.getMailContentTitle(); try < SendMailUtil.sendMail(mailToAddress, mailTitle, mailBody); >catch (Exception e) < e.printStackTrace(); >> if (exeState != 0) < // 执行失败 taskDao.updateStateByPrimaryKey(taskId, (short) 40, new Date()); // 邮件参数 param.setState(40); String mailBody = SendMailUtil.beautyMailHtmlLayout(param); String mailToAddress = param.getMailToUser(); try < SendMailUtil.sendMail(mailToAddress, "回溯任务", mailBody); >catch (Exception e) < e.printStackTrace(); >> ExecuteTaskModel taskModel = new ExecuteTaskModel(); taskModel.setId(taskId); log.info("remove task in thread,id:<>", taskId); boolean remove; if (concurrentHashSet.contains(taskModel)) < remove = concurrentHashSet.remove(taskModel); >log.info("remove from set success set:<>", concurrentHashSet); log.info("execute task thread exit!"); System.out.println("Process exitValue: " + exeState); assert process != null; process.destroy(); > > 

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Ошибка «Cannot run program» на Linux: возможные причины и способы ее исправления

Если вы работаете с операционной системой Linux, вы, возможно, столкнулись с ошибкой «Cannot run program». Эта ошибка может возникать по разным причинам, и в этой статье мы рассмотрим некоторые из них и способы исправления.

Причины ошибки «Cannot run program»

Ошибки «Cannot run program» могут быть вызваны различными проблемами. Одна из наиболее распространенных причин — отсутствие разрешения на выполнение файлов. Если у вас нет разрешения на запуск файла, вы получите сообщение «Cannot run program».

Читайте также:  Linux with ssd and hdd

Еще одной причиной ошибки может быть неверно указанный путь к файлу. Если вы не указали правильный путь к файлу, ваша программа не сможет выполнить его.

Необходимым условием для запуска программы является наличие необходимых библиотек и зависимостей. Если на вашей системе отсутствуют какие-либо зависимости, программа может не запуститься, и вы получите ошибку «Cannot run program».

Также может возникнуть ошибка, если вы пытаетесь запустить программу под учетной записью, которой не хватает прав на выполнение данной программы.

Способы исправления ошибки «Cannot run program»

Существует несколько способов исправления ошибки «Cannot run program» на Linux.

Проверьте разрешения на файл

Первым шагом к исправлению ошибки является проверка разрешений на файл. Убедитесь, что вы имеете права на выполнение файла, используя команду ls -l . Если у вас нет прав на выполнение файла, используйте команду chmod +x filename для предоставления прав на выполнение.

Проверьте путь к файлу

Если у вас права на выполнение файла, то следующим шагом является проверка пути к файлу и убедиться, что вы указываете правильный путь. Попробуйте указать полный путь к файлу, включая его имя, и попробуйте выполнить программу еще раз.

Установите зависимости

Если программа требует определенных библиотек или зависимостей, убедитесь, что они установлены на вашей системе. Попробуйте установить недостающие пакеты используя менеджер пакетов вашего дистрибутива.

Запустите программу от имени администратора

Если все еще не удается запустить программу, попробуйте запустить ее от имени администратора (с помощью команды sudo ). Это может помочь в тех случаях, когда вам не хватает прав для выполнения программы из-за ограничений безопасности.

Обратитесь к сообществу

Если вы все еще не можете решить проблему, обратитесь к сообществу Linux для получения помощи. Существует множество форумов и сайтов для обсуждения проблем Linux, и, возможно, вы найдете ответ на свой вопрос там.

Заключение

Ошибка «Cannot run program» на Linux может возникать по разным причинам, включая недостаток прав на выполнение файла, неверный путь к файлу, отсутствующие зависимости или ограничения безопасности. Выполнение вышеописанных шагов может помочь в решении проблемы.

Источник

Unable to run executable files at all

What I am trying to achieve: I am now just trying to install the latest version of eclipse (4.7 AKA Oxygen) using the executable file (not .exe and is 32-bit called «eclipse-inst») on a 32-bit OS (Ubuntu MATE 16.04) using a 32-bit processor. Of course, it returns with the text above.

What I am using to run Linux:

  • A Banana Pi M3 (Specific specs at: https://www.cnx-software.com/wp-content/uploads/2015/07/Banana_PI_BPI-M3.jpg)
    • A7 ARM Processor
    • 2GB of RAM
    • Ubuntu MATE 16.04 (32-bit)

    Things to note:

    • Installer is made for 32-bit Linux which I’m using
    • Again, I’m using ARM
    • The file I’m trying to install is in /home/user/Downloads. Please let me know if there is a specific place I need to install from. That would be very helpful.

    R U speaking of Linux commands in /bin or a written script? Mount is a command to make file systems (drives)accessible. Are you trying to mount a drive? Typing ‘man mount’ in a terminal will give pertinent info on the command. More info as to what you wish to accomplish and what trouble you are actually having can give us a starting point to get you thru this dilemma.

    Are you trying to run a Windows executable file with the extension .exe? Executable files in linux are different and they are marked executable via the permissons, not via the extension. Some Windows exe files can be run via Wine (if you install the linux program package wine ).

    And no, I’m not trying to run Windows executables. They do not have .exe at the end and are made to be ran on linux.

    1. ./program or just double-clicking. From what I’ve heard I should be able to right-click the file and have a ‘run’ button but I only have an open. When I select it nothing happens. 2. Not necessarily, but when I do ./program it gives an error about the format. Not just on one file but from every other executable I’ve tried. 3. Nothing happens, nothing opens. I’ve tried it on a few applications/installers that are for Linux that should have a window appear after starting. Such as Eclipse or PyCharm.

    @DavidFoerster understood your problem perfectly well. When people usually say 32-bit installer, they mean installers for the x86 Intel architecture as opposed to the 64-bit x86-64/amd64 architecture. You can’t run x86 software on ARM, whether or not it’s 32-bit or 64-bit makes no difference.

    1 Answer 1

    You can’t run Intel x86 executables on ARM CPUs because the latter don’t understand the instruction set of the former (even though both have a word length of 32 bit).

    However, you can install Eclipse from Ubuntu’s software repositories which contains an armhf build of it:

      Enable the “universe” repository section (see How do I enable the “Universe” repository?), if you haven’t already, and update the package list after the change:

    Unfortunately, the version of Eclipse in the repositories is pretty old (over 3 years) and building a recent version from source is non-trivial. I also doubt that you’re going to have much fun with a resource-heavy interactive application like Eclipse on a low-resource system with an ARM A7 like yours. If you want to develop software for ARM systems you may want to look into cross-compilation which would allow you to develop software on your (x86-compatible) desktop computer which then runs on other platforms (ARM).

    Источник

    My program cannot run with «command not found» error

    I just switched from Windows to Ubuntu 11.10. I wrote the following code in C with the text editor and saved it as HelloWorld.c in Documents.

    cd Documents gcc HelloWorld.c 

    @NickShvelidze Compilers pretty much always set +x for you; you do not need to chmod the executable produced by a compiler. The only common situation where gcc fails to make it executable is if it’s creating the file in a filesystem that doesn’t support or allow it (in which case chmod immediately afterwards would fail too). Also, 777 should be avoided. There is no need to make it readable, writable, and executable by all users; if it were necessary to run chmod , then chmod +x a.out would be sufficient.

    3 Answers 3

    Since you’re running an executable in the current working directory, you should prefix it with ./ . So for your program run it as ./a.out .

    Explanation

    The terminal searches for executables in $PATH . This is a Unix environment variable that lists directories containing system binaries (such as ls , echo , or gcc ). If you call an executable that’s not in a $PATH directory (such as a.out ), you need to indicate its absolute path in the file system.

    In the terminal . is a synonym for the current working directory, thus ./a.out . You could equally well call /home/yihang/Documents/a.out .

    To further elaborate on this, the «./» serves as a «right here», command. It’s a bit redundant, but useful in the sense that you know you’ll be executing something.

    @yihang: Please consider to mark this question as answered, by clicking the gray/green circle on the left side of the answer you like most.

    @Ruben Bakker: Actually, it’s not at all redundant. Unlike Windows, Linux does not default to looking in the current, or default, directory. So, if it’s not in the path, you need to specify the directory, whatever it is.

    When you run commands on Linux it searches all the directories listed in the PATH environment variable, and if it doesn’t find the command there then you get the message you’ve seen.

    Typically it looks like this:

    That means it will look first in /usr/local/bin . If it doesn’t find it there it’ll look in /usr/bin , and so on.

    In fact, this is very similar on DOS/Windows: there’s a variable called %PATH% that does exactly the same thing.

    The difference is that, on Windows, the current directory is also searched. Unix considers this bad because a local file (such as malware) can override important system programs accidentally.

    If you prefer that though, you can make Linux work the same way by adding . to the path:

    (That says set PATH to .: plus the existing contents of $PATH .)

    It ends up looking something like this (it may be different on your machine):

    If you’d rather not do that, you can simply run each program by specifying the directory explicitly:

    Источник

Оцените статью
Adblock
detector