Reputation: 670
I'm running the task "grunt-ssh" github/ssh, and it works fine, except for the cd command, here is my code:
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
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.
Any ideas?
Upvotes: 2
Views: 257
Reputation: 414046
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.
This should work:
command: ['sh -c "cd /; ls"'],
Upvotes: 2