grunt-ssh
grunt-ssh copied to clipboard
Can't seem to change directory
My attempts to use cd to change to the directory I wish to run further commands in does not appear to be working. The verbose log does not display much either.
Looks like its because each command is running in a separate session. When a session is ended (Stream :: exit
), it will lose the current directory.
How are you running it? Can you try something like this:
sshexec: {
test: {
command: ['pwd', 'cd /tmp', 'pwd'],
options: {
config: 'myhost'
}
}
}
I think that should work.
Otherwise, a work around might be:
sshexec: {
test: {
command: 'pwd; cd /tmp; pwd',
options: {
config: 'myhost'
}
}
}
Yeah, I have the same issue. Doing command: ['pwd', 'cd /tmp', 'pwd'] is always in /root.
In command: 'pwd; cd /tmp; pwd', works, but is no cool.
Tks
Same issue for me. Commands chaining using array would be a very appreciated feature for automated deployment.
Yeah, I agree. This would be a good feature.
The execCommand
function is taking one command at a time (using command.shift()
) and passing this to ssh2's exec
function. As we are not closing the connection until all commands are finished, I had hoped that any changes to the environment would be kept, but that doesn't seem to be the case.
Maybe we need to use the shell()
function from ssh2 instead. This could be a separate task, as it will behave differently to exec
.
Anything new about that ? It is really a needed feature since the cwd is very important to develop/deploy.
I get around this by creating bash script file, use sftp to copy it over and then sshexec to chmod and run it. Much neater than placing a bunch of shell commands in a JS array.
On Wednesday, November 20, 2013, Marvin Roger wrote:
Anything new about that ? It is really a needed feature since the cwd is very important to develop/deploy.
— Reply to this email directly or view it on GitHubhttps://github.com/andrewrjones/grunt-ssh/issues/24#issuecomment-28919610 .
David J. Bradshaw )'( [email protected]
'The people we think are a little weird are the ones who change the world'
- Simon Sinek
Didn't even think about that ! Thanks a lot for the idea. :)
You might also want to check out grunt-hash-manifest to checksum the files your uploading. I had a tar.gz file get corrupted the other week and it trashed a load stuff when I tried to untar it.
The version of grunt-hash-manifest on NPM has a bug in it when dealing with binary files, I've fixed it and sent a pull request, but the project seems a bit dead, so you might want to use my fork for now.
https://github.com/davidjbradshaw/grunt-hash-manifest
I've also written a couple of shell scripts to check the manifest file on the remote server.
https://gist.github.com/davidjbradshaw/7438465
It might be useful for some sensitive environments. Thanks again !
Just a quick thought:
An easy way to use an array of commands
myTask {
command: ['cd my/path', 'ls -la'].join(';')
}
Thanks @aarontropy :+1: