AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题

问题[sh](computer)

Martin Hope
Richard Barraclough
Asked: 2023-10-22 10:46:40 +0800 CST

sh 源权限被拒绝尝试调用另一个脚本

  • 5

你能让一个sh脚本调用另一个脚本吗?(显然不是。)

rwb@calleva:~/source$ ls -l
total 8
-rwxr--r-- 1 rwb rwb 50 Oct 22 03:38 caller.sh
-rwxr--r-- 1 rwb rwb 30 Oct 22 03:36 sourced.sh
rwb@calleva:~/source$ cat sourced.sh
#!/bin/sh

echo "sourced.sh"

rwb@calleva:~/source$ ./sourced.sh
sourced.sh
rwb@calleva:~/source$ cat caller.sh
#!/bin/sh

echo "caller.sh"

source ./sourced.sh

rwb@calleva:~/source$ ./caller.sh
caller.sh
./caller.sh: 5: source: Permission denied
rwb@calleva:~/source$
sh
  • 1 个回答
  • 13 Views
Martin Hope
hat
Asked: 2021-02-23 06:53:37 +0800 CST

sh源找不到文件

  • 8

我有一个 Ubuntu 20.04 安装。我似乎无法使用shUbuntu 的默认值来获取文件dash。

我有一个文件,可以说build.env,其中包含一些环境变量,如下所示:

构建环境:

SOMEVAR=something
A_VAR=some_value

我可以在 bash 上使用. build.envor来获取它source build.env。但是,如果我尝试. build.env使用 sh,我会得到

sh: 1: .: build.env: not found. 

我可以stat或cat文件,但我无法获取它。为什么?

sh dash-shell
  • 1 个回答
  • 575 Views
Martin Hope
7o7o
Asked: 2020-06-08 10:43:05 +0800 CST

通过具有特殊权限的脚本修改文件

  • 5

可能这是基本的..但是我没有找到对正在发生的事情的解释..我拥有这些具有这些特定权利的文件:

图片:

所以 modtp2 是我用来更改 tp2 内容的 shell 脚本,用户名为“user1”,该用户不属于“SYS”组:

modtp2 脚本

图片:

我将用户更改为“user1”并尝试执行脚本,但我总是收到此错误:

图片:

但是,据我所知,它应该被执行,因为即使 SUID 设置不正确,SGID 也是。因此,有效的GID 应该是SYS 在执行脚本时的GID,该脚本有写入tp2 的权限。

我知道这是一个错误的解释,因为许可被拒绝,但你能纠正我吗?有效的 GID 是否仅适用于当前脚本而不适用于文本文件?

linux sh
  • 1 个回答
  • 75 Views
Martin Hope
Kamil Maciorowski
Asked: 2020-02-18 14:32:14 +0800 CST

`sh -c 'some shell code' sh` 中的第二个 sh 是什么?

  • 15

问题

我遇到了以下代码段:

sh -c 'some shell code' sh …

(其中…表示零个或多个附加参数)。

我知道第一个sh是命令。我知道sh -c应该执行提供的 shell 代码(即some shell code)。第二个目的是什么sh?


免责声明

类似或相关的问题有时会在答案中正确使用后作为后续问题出现,sh -c提问者(或其他用户)想详细了解答案的工作原理。或者它可能是“这段代码做什么?”类型的更大问题的一部分。当前问题的目的是在下面提供一个规范的答案。

此处涵盖的主要问题、类似或相关问题是:

  1. 中的第二个sh是sh -c 'some shell code' sh …什么?
  2. 中的第二个bash是bash -c 'some shell code' bash …什么?
  3. find-sh里面有什么find . -exec sh -c 'some shell code' find-sh {} \;?
  4. 如果some shell code在一个 shell 脚本中并且我们调用./myscript foo …, thenfoo将被称为$1在脚本中。但是sh -c 'some shell code' foo …(或bash -c …)指的foo是$0。为什么会出现差异?
  5. 使用sh -c 'some shell code' foo …where foois a "random" 参数有什么问题?尤其是:

    • sh -c 'some shell code' "$variable"
    • sh -c 'some shell code' "$@"
    • find . -exec sh -c 'some shell code' {} \;
    • find . -exec sh -c 'some shell code' {} +

    我的意思是我可以使用$0代替$1inside some shell code,它不会打扰我。会发生什么坏事?

以上某些问题可能被认为是现有问题(例如这个问题)的重复(可能是跨站点重复)。我仍然没有找到旨在向想要理解的初学者解释问题的问题/答案,sh -c …以及在高质量答案中观察到的据称无用的额外论点。这个问题填补了空白。

shell-script sh
  • 1 个回答
  • 1020 Views
Martin Hope
sbh7600
Asked: 2019-12-03 15:53:33 +0800 CST

显示度数符号 bash/tcl

  • 5

我试图获取一个登录脚本来显示度数符号,但它不显示它。

Here is the weather.sh
METRIC="1"  # 0 for F, 1 for C
# Fill in form to find your weather code here:
# http://netweather.accuweather.com/signup-page2.asp
# If code has a space remove it or replace it with %20 or a dash; -
LOCCOD="struer"  #Example: NAM|MX|MX009|MEXICO-CITY

if [ "$weather" != "0" ] ; then
  weather=`curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$LOCCOD \
  | grep -E '<description>(Currently|High)' \
  | sed -e 's/.*<description>\(.*\)/\1/' -e 's/\(.*\) &lt.*/\1/' -e 's/\(&#38;#176;\)//'`
  if [ "`echo "$weather" | wc -l`" -eq "3" ] ; then
    echo "Weather......: `echo "$weather" | head -1`"
    echo "Today........: `echo "$weather" | head -2 | tail -1`"
    echo "Tomorrow.....: `echo "$weather" | tail -1`"
  fi
fi

但是当我登录时它只显示:&#176;C

但如果我这样做:echo $'\xc2\xb0'C在腻子中,它显示正常吗?

什么给了,我该如何解决?

bash sh
  • 2 个回答
  • 345 Views
Martin Hope
Paul
Asked: 2019-09-05 02:54:23 +0800 CST

带有字节顺序标记的 sh 脚本

  • 6

Linux“sh”是否能够在开头运行带有 BOM(字节顺序标记)的 Unicode 文本脚本文件?

我真的需要这个并且不想删除 BOM。

linux sh
  • 1 个回答
  • 212 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve