相关疑难解决方法(0)

如何使用Bash抑制命令的所有输出?

我有一个运行带参数的程序的bash脚本.该程序输出一些状态(这样做,这样做......).这个程序没有选择安静.如何防止脚本显示任何内容?

我正在寻找类似windows"echo off"的东西.

bash shell scripting echo

276
推荐指数
5
解决办法
31万
查看次数

是否可以抑制 NPM 对其正在运行的命令的回显?

我有一个 bash 脚本,可以启动服务器,然后运行一些功能测试。它必须在一个脚本中发生,所以我在后台运行服务器。这一切都通过 2 个 npm 命令发生:start:nologtest:functional.

都好。但是输出中有很多我不关心的问题:

? ./functional-tests/runInPipeline.sh

(... "good" output here)

> @co/foo@2.2.10 pretest:functional /Users/jcol53/Documents/work/foo
> curl 'http://localhost:3000/foo' -s -f -o /dev/null || (echo 'Website must be running locally for functional tests.' && exit 1)


> @co/foo@2.2.10 test:functional /Users/jcol53/Documents/work/foo
> npm run --prefix functional-tests test:dev:chromeff


> @co/foo-functional-tests@1.0.0 test:dev:chromeff /Users/jcol53/Documents/work/foo/functional-tests
> testcafe chrome:headless,firefox:headless ./tests/**.test.js  -r junit:reports/functional-test.junit.xml -r html:reports/functional-test.html --skip-js-errors
Run Code Online (Sandbox Code Playgroud)

那里有很多我不需要的行。我可以抑制@co/foo-functional-tests等行吗?他们没有告诉我任何值得...

npm run -s 杀死命令的所有输出,这不是我要找的。

这可能是不可能的,但这没关系,我很好奇,也许我错过了什么......

node.js npm npm-scripts

8
推荐指数
1
解决办法
835
查看次数

如何在执行 shell 脚本 Linux 时关闭 echo

这是我正在做的一件简单的事情

 echo "please enter a command"
 read x
 $x
 checkexitstatus()
 {...}
Run Code Online (Sandbox Code Playgroud)

checkexit status 是在其他地方创建的 ifloop 只是为了检查退出状态

我想知道的是,当我运行 $x 时,它不会显示在屏幕上,我想知道是否可以不将输出重定向到文件

linux bash shell echo

6
推荐指数
3
解决办法
5万
查看次数

当我的命令被超时杀死时,如何使“已终止”消息静音?

通过引用bash:静默地杀死后台函数进程在bash 中使命令超时而没有不必要的延迟,我编写了自己的脚本来为命令设置超时以及使kill消息静音。

但是当我的进程被终止时,我仍然收到“已终止”消息。我的代码有什么问题?

#!/bin/bash
silent_kill() {
    kill $1 2>/dev/null
    wait $1 2>/dev/null
}
timeout() {
    limit=$1 #timeout limit
    shift
    command=$* #command to run
    interval=1 #default interval between checks if the process is still alive
    delay=1 #default delay between SIGTERM and SIGKILL
    (
        ((t = limit))
        while ((t > 0)); do
            sleep $interval;
            #kill -0 $$ || exit 0
            ((t -= interval))
        done
        silent_kill $$
        #kill -s SIGTERM $$ && kill -0 $$ || exit 0 …
Run Code Online (Sandbox Code Playgroud)

bash shell

5
推荐指数
1
解决办法
1179
查看次数

标签 统计

bash ×3

shell ×3

echo ×2

linux ×1

node.js ×1

npm ×1

npm-scripts ×1

scripting ×1