Git Product home page Git Product logo

Comments (11)

andrewrjones avatar andrewrjones commented on August 17, 2024

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.

favio41 avatar favio41 commented on August 17, 2024

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.

noirbizarre avatar noirbizarre commented on August 17, 2024

Same issue for me.
Commands chaining using array would be a very appreciated feature for automated deployment.

from grunt-ssh.

andrewrjones avatar andrewrjones commented on August 17, 2024

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.

marvinroger avatar marvinroger commented on August 17, 2024

Anything new about that ? It is really a needed feature since the cwd is very important to develop/deploy.

from grunt-ssh.

davidjbradshaw avatar davidjbradshaw commented on August 17, 2024

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.

marvinroger avatar marvinroger commented on August 17, 2024

Didn't even think about that ! Thanks a lot for the idea. :)

from grunt-ssh.

davidjbradshaw avatar davidjbradshaw commented on August 17, 2024

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.

marvinroger avatar marvinroger commented on August 17, 2024

It might be useful for some sensitive environments. Thanks again !

from grunt-ssh.

aarontropy avatar aarontropy commented on August 17, 2024

Just a quick thought:
An easy way to use an array of commands

myTask {
    command: ['cd my/path', 'ls -la'].join(';')
}

from grunt-ssh.

brunowego avatar brunowego commented on August 17, 2024

Thanks @aarontropy 👍

from grunt-ssh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.