I'm running the task "grunt-ssh" github/ssh, and it works fine, except for the cd command, here is my code:
我正在运行任务“grunt-ssh”github / ssh,它运行正常,除了cd命令,这是我的代码:
grunt.initConfig({
sshexec: {
connect: {
command: ['ls'],
options: {
host: 'some_host',
username: 'user',
password: 'pass'
}
}
});
the output for this is for example is: /folder1, /folder2, /etc, /etc
例如,它的输出是:/ folder1,/ folder2,/ etc,/ etc
but when I run the same task with e.g.:
但当我用例如:
command: ['cd /', 'ls'],
(the output it should be : /root, /foldera, /folderb, /etc, /etc) but instead of that i get the same : /folder1, /folder2, /etc, /etc it seem thet th command "cd /" i not executed.
(输出应该是:/ root,/ foldera,/ folderb,/ etc,/ etc)但不是我得到相同的:/ folder1,/ folder2,/ etc,/ etc它似乎是命令“cd / “我没有被处决。
Any ideas?
有任何想法吗?
1 个解决方案
#1
2
I suspect that the cd
command is executed, but in such a way that it doesn't affect the subsequent command. It's executed as its own process, so once it's done the next process starts off in exactly the same directory.
我怀疑执行cd命令,但这样做不会影响后续命令。它作为自己的进程执行,因此一旦完成,下一个进程就会在完全相同的目录中启动。
This should work:
这应该工作:
command: ['sh -c "cd /; ls"'],
#1
2
I suspect that the cd
command is executed, but in such a way that it doesn't affect the subsequent command. It's executed as its own process, so once it's done the next process starts off in exactly the same directory.
我怀疑执行cd命令,但这样做不会影响后续命令。它作为自己的进程执行,因此一旦完成,下一个进程就会在完全相同的目录中启动。
This should work:
这应该工作:
command: ['sh -c "cd /; ls"'],