该脚本在终端中运行但不适用于 js exec()
The script is working in terminal but not work with js exec()
echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"
此代码在终端上运行。
但是如果我尝试 运行 使用 javascript exec() 的脚本,它会给出这样的错误。
Error: Command failed: echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:///g" -e "s/ssh/////g" -e "s/git@/https:///g"
sed: -e expression #1, char 6: unknown option to `s'
at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:673:12) {
killed: false,
code: 1,
signal: null,
cmd: 'echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:///g" -e "s/ssh/////g" -e "s/git@/https:///g"'
}
++++++stdout:
```````stderr: sed: -e expression #1, char 6: unknown option to `s'
这是代码
await exec(
`echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"`,
(error, stdout, stderr) => {
console.log("linux test");
console.log("------error: ", error);
console.log("++++++stdout: ", stdout);
console.log("```````stderr: ", stderr);
}
);
我该如何解决?
使用这个固定代码:
await exec(
String.raw`echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"`,
(error, stdout, stderr) => {
console.log("linux test");
console.log("------error: ", error);
console.log("++++++stdout: ", stdout);
console.log("```````stderr: ", stderr);
}
);
echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"
此代码在终端上运行。
但是如果我尝试 运行 使用 javascript exec() 的脚本,它会给出这样的错误。
Error: Command failed: echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:///g" -e "s/ssh/////g" -e "s/git@/https:///g"
sed: -e expression #1, char 6: unknown option to `s'
at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:673:12) {
killed: false,
code: 1,
signal: null,
cmd: 'echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:///g" -e "s/ssh/////g" -e "s/git@/https:///g"'
}
++++++stdout:
```````stderr: sed: -e expression #1, char 6: unknown option to `s'
这是代码
await exec(
`echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"`,
(error, stdout, stderr) => {
console.log("linux test");
console.log("------error: ", error);
console.log("++++++stdout: ", stdout);
console.log("```````stderr: ", stderr);
}
);
我该如何解决?
使用这个固定代码:
await exec(
String.raw`echo git@github.com:hasantezcan/journey-of-2021.git | sed -e "s/:/\//g" -e "s/ssh\/\/\///g" -e "s/git@/https:\/\//g"`,
(error, stdout, stderr) => {
console.log("linux test");
console.log("------error: ", error);
console.log("++++++stdout: ", stdout);
console.log("```````stderr: ", stderr);
}
);