Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行路径名中存在空格如何处理,单引号转义无效 #2

Closed
Tback1 opened this issue Oct 3, 2021 · 2 comments
Closed

Comments

@Tback1
Copy link

Tback1 commented Oct 3, 2021

例如这样的路径 "node d:\'4 Node'\4\test.js"

.--------.---------------.------------------------------.----------.
| 任务ID | 表达式 | 执行命令 | 错误信息 |
+--------+---------------+------------------------------+----------+
| 1 | 0/5 * * * * ? | node d:'4 Node'\4\test.js | nil |
'--------'---------------'------------------------------'----------'
输入任意键退出

{"level":"info","msg":"执行命令: node d:\'4 Node'\4\test.js 输出: node:internal/modules/cjs/loader:930\r\n throw err;\r\n

实际识别成了d:\4的路径,对空格没有很好地处理

试过
"node d:\'4 Node'\4\test.js"
"node d:\4 Node\4\test.js"
"node d:\\"4 Node"\\4\\test.js"
路径转义始终失败

@hezhizheng
Copy link
Owner

hezhizheng commented Oct 3, 2021

例如这样的路径 "node d:'4 Node'\4\test.js"

.--------.---------------.------------------------------.----------. | 任务ID | 表达式 | 执行命令 | 错误信息 | +--------+---------------+------------------------------+----------+ | 1 | 0/5 * * * * ? | node d:'4 Node'\4\test.js | nil | '--------'---------------'------------------------------'----------' 输入任意键退出

{"level":"info","msg":"执行命令: node d:'4 Node'\4\test.js 输出: node:internal/modules/cjs/loader:930\r\n throw err;\r\n

实际识别成了d:\4的路径,对空格没有很好地处理

试过 "node d:\'4 Node'\4\test.js" "node d:\4 Node\4\test.js" "node d:\\"4 Node"\\4\\test.js" 路径转义始终失败

建议尽量贴上 config.json 的配置文件
此问题可以尝试先进入 d:\4 Node\4 这个目录再执行 node test.js 命令
即在配置文件设置 cmd 为 "d: && cd d:\4 Node\4 && node test.js"

cmd 环境
{
   "app": {
    "model": "s",
    "exec_mode":"",
    "crontab_cmd": [
      {
        "crontab": "0 0/1 * * * ?",
        "cmd": "d: && cd d:\\4 Node\\4 && node test.js"
      }
    ]
  }
}
bash 环境
{
    "app": {
        "model": "s",
        "exec_mode": "bash",
        "crontab_cmd": [
            {
                "crontab": "0 0/1 * * * ?",
                "cmd": "cd /d/4\\ Node/4/ && node test.js"
            }
        ]
    }
}

@Tback1

@Tback1
Copy link
Author

Tback1 commented Jan 25, 2022

@hezhizheng 谢谢,已经这个思路可以解决。我采用的是另一个思路,直接改名4 node4_node 但是迟早会遇到无法改名绕过的。还是得采取先进入目录的思路

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants