我已经创建了一个 bash 脚本,但是当我尝试执行它时,我得到
#!/bin/bash no such file or directory
Run Code Online (Sandbox Code Playgroud)
我需要运行命令:bash script.sh让它工作。
我怎样才能解决这个问题?
我目前在 debian (wheezy/amd64) 上有一个奇怪的问题。
我创建了一个 chroot 来安装服务器(抱歉,我无法提供更多详细信息)。让我们称其为 path /chr_path/。为方便起见,我使用 debootstrap(也是 wheezy/amd64)初始化了这个 chroot。
在 chroot 中一切似乎都运行良好,但是当我启动服务器的安装程序脚本时,我得到了 :(
zsh: Not found /some_path/perl由于某些原因,安装程序包含一个 perl 二进制文件)
当然,我检查了/some_path/位置并找到了“perl”二进制文件。file在 chroot 环境中返回:
/some_path/perl ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
Run Code Online (Sandbox Code Playgroud)
该文件存在,似乎没问题,具有正确的权限。我可以在它上面使用file, ls,vim但是一旦我尝试执行它 -./perl例如 - 我得到 : zsh: Not found ./perl。
这种情况对我来说是可以理解的。而且 :
/chr_path/some_path/perl …当我运行chroot命令时出现错误:
failed to run command ‘/bin/bash’: No such file or directory
Run Code Online (Sandbox Code Playgroud) 如果没有读取权限,是否可以执行脚本?在 root 模式下,我制作了一个脚本,我希望其他用户执行此脚本但不读取它。我确实chmod禁止读写但允许执行,但是在用户模式下,我看到消息说:权限被拒绝。
我备份到 NTFS 驱动器,嗯,这个备份确实被证明是必要的。但是,NTFS 驱动器弄乱了权限。我想将它们恢复到正常状态,而无需手动修复每个文件。
一个问题是突然我所有的文本文件都获得了执行权限,这是错误的。所以我试过:
sudo chmod -R a-x folder\ with\ restored\ backup/
Run Code Online (Sandbox Code Playgroud)
但这是错误的,因为它也x从目录中删除了权限,这使得它们不可读。
在这种情况下,正确的命令是什么?
在 32 位 Linux 系统上,调用这个
$ /lib/libc.so.6
Run Code Online (Sandbox Code Playgroud)
而在 64 位系统上,这
$ /lib/x86_64-linux-gnu/libc.so.6
Run Code Online (Sandbox Code Playgroud)
在 shell 中,提供如下输出:
GNU C Library stable release version 2.10.1, by Roland McGrath et al.
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.0 20090506 (Red Hat 4.4.0-4).
Compiled on a Linux >>2.6.18-128.4.1.el5<< system on 2009-08-19.
Available extensions:
The C …Run Code Online (Sandbox Code Playgroud) 我有一个简单的脚本:
#!/usr/bin/env ruby --verbose
# script.rb
puts "hi"
Run Code Online (Sandbox Code Playgroud)
在我的 OSX 机器上,它运行良好:
osx% ./script.rb
hi
Run Code Online (Sandbox Code Playgroud)
但是,在我的 linux 机器上,它会引发错误
linux% ./script.rb
/usr/bin/env: ruby --verbose: No such file or directory
Run Code Online (Sandbox Code Playgroud)
如果我手动运行 shebang 线,它工作正常
linux% /usr/bin/env ruby --verbose ./script.rb
hi
Run Code Online (Sandbox Code Playgroud)
但是如果我打包ruby --verbose成一个参数,我可以复制错误env
linux% /usr/bin/env "ruby --verbose" ./script.rb
/usr/bin/env: ruby --verbose: No such file or directory
Run Code Online (Sandbox Code Playgroud)
所以我认为这是如何env解释shebang线的重置的问题。我正在使用 GNU coreutils 8.4 env:
linux% /usr/bin/env --version
env (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL …Run Code Online (Sandbox Code Playgroud) 与 Bash 的 source可以在不设置执行位的情况下执行脚本。这是记录在案的预期行为,但这不是反对使用执行位吗?
我知道,这source不会创建子shell。
有没有机会知道在 Linux 下如何构建二进制文件?(和或其他 Unix)
编译器、版本、时间、标志等...
我查看readelf并找不到太多内容,但可能还有其他方法可以分析二进制代码/部分等...
你知道怎么提取吗?