bash变量替代

发布于 2025-01-27 10:41:13 字数 1275 浏览 2 评论 0原文

我想通过命令 db-out 。 Prodigy安装在a Google Compegute Engine vm,但是,我不是它的所有者,为此原因,我正在尝试的是这样:

# Assume `test1` exists
DB_NAME="test1"
#  `super_user` is Prodigy owner's home directory.
sudo runuser -l super_user -c 'python3 -m prodigy db-out "$DB_NAME" > ./"$DB_NAME".jsonl'

以前的命令应生成test1.jsonl文件,该文件应在super_user home Directory中找到。但是,没有生成test1.jsonl。顺便说一句,当运行这些行时,不会显示警告或错误。

但是,当我直接运行以下命令时:

sudo runuser -l super_user -c 'python3 -m prodigy db-out test1 > ./test1.jsonl'

test1.jsonl文件是正确生成的,如前所述和解释。为什么?

其他注释/更新:

  1. 不需要解释 runuser 或 db-out 命令正在做。我认为错误与(可能是?)错误的变量替换更相关,而我现在没有看到。

I want to export the results of a Prodigy tagging session through the command db-out. Prodigy is installed in a Google Compute Engine VM, however, I am not the owner of it and for that reason, what I am attempting, looks like this:

# Assume `test1` exists
DB_NAME="test1"
#  `super_user` is Prodigy owner's home directory.
sudo runuser -l super_user -c 'python3 -m prodigy db-out "$DB_NAME" > ./"$DB_NAME".jsonl'

The previous commands should generate a test1.jsonl file, which should be found in the super_user home directory; however, no test1.jsonl is generated. BTW, when those lines are run, no warning or error is displayed.

Nevertheless, when I directly run the following command:

sudo runuser -l super_user -c 'python3 -m prodigy db-out test1 > ./test1.jsonl'

test1.jsonl file is correctly generated, as expected and explained before. Why?

Additional notes / updates:

  1. There is no need into explaining what the runuser or db-out commands are doing. I think the error is more related to a (possibly?) wrong variable substitution from my side, that I am not seeing right now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2025-02-03 10:41:13

在我注意 Gordon Davidson ,强烈建议谁修订),我设法解决了我的原始问题。校正的代码看起来如下:

DB_NAME="test1"
sudo runuser -l super_user -c "python3 -m prodigy db-out $DB_NAME > ./$DB_NAME.jsonl"

为了清楚更改,它们是:

  1. 单引号被双重替换。
  2. 内部双引号被丢弃。

之后,该脚本可以按原样运行。如果我理解这篇文章正确地,可能还有其他有效的答案;但是,这是现在起作用的。

谢谢。

After addressing my attention to this post (which was kindly suggested by Gordon Davidson, and whose revision is highly suggested), I managed to solve my original issue. The corrected code looks like follows:

DB_NAME="test1"
sudo runuser -l super_user -c "python3 -m prodigy db-out $DB_NAME > ./$DB_NAME.jsonl"

Just to make changes clear, they are:

  1. The single quotation marks were replaced by double ones.
  2. The inner double quotation marks were discarded.

Afterwards, the script works as it is supposed to be. If I understand this post correctly, there could be some other valid answers; however this one works for now.

Thank you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文