Comments (11)
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'
}
}
}
from grunt-ssh.
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
from grunt-ssh.
Same issue for me.
Commands chaining using array would be a very appreciated feature for automated deployment.
from grunt-ssh.
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
.
from grunt-ssh.
Anything new about that ? It is really a needed feature since the cwd is very important to develop/deploy.
from grunt-ssh.
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//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
from grunt-ssh.
Didn't even think about that ! Thanks a lot for the idea. :)
from grunt-ssh.
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
from grunt-ssh.
It might be useful for some sensitive environments. Thanks again !
from grunt-ssh.
Just a quick thought:
An easy way to use an array of commands
myTask {
command: ['cd my/path', 'ls -la'].join(';')
}
from grunt-ssh.
Thanks @aarontropy 👍
from grunt-ssh.
Related Issues (20)
- Exec task sometimes does not return a result HOT 1
- Support for ssh proxy host connection
- Could support multiple remote servers connection? HOT 2
- Delete mode HOT 1
- sftp should fail on error
- Cannot download all files in folder (using wildcard) on Windows due to path construction problem
- Fatal error: Argument must be a string
- Download method - cannot locate files on the remote server HOT 3
- Switching the user (su) seems to interrupt the connection for submitting further commands
- agent does not use ~/.ssh/config HOT 1
- More features HOT 1
- Update grunt dependency HOT 2
- Way to prompt for password? HOT 1
- Multiple upload paths for the same files
- Publish a release to npm HOT 1
- Request: update referenced ssh2 version HOT 3
- Error: All configured authentication methods failed
- download mode failure (ssh2 outdated)
- pty for root user and sudo commands HOT 2
- Does sshexec wait for command completing?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-ssh.