Giter VIP home page Giter VIP logo

Comments (5)

yegor256 avatar yegor256 commented on August 28, 2024

Good question. This is how I would do it:

import com.jcabi.log.Logger;
import com.jcabi.ssh.SSH;
shell.exec(
  String.format(
    "cat > %s",
    SSH.escape(file_name)
  ),
  new FileInputStream(file),
  Logger.stream(Level.INFO, true),
  Logger.stream(Level.WARNING, true)
);

from jcabi-ssh.

zhaozhiming avatar zhaozhiming commented on August 28, 2024

ok, thank you.

from jcabi-ssh.

davidhtien avatar davidhtien commented on August 28, 2024

Could this example be explained in more detail? I don't really see what's going here. Also I want to scp a byte array that is currently stored in memory would that be possible?

from jcabi-ssh.

devent avatar devent commented on August 28, 2024

A little bit old, but here is the explanation.

cat > %s command will read input from stdin and save it in the file %s (that will be replaced by the real file name, stored in file_name). The stdin is streamed in from the created FileInputStream(file).

from jcabi-ssh.

lubars avatar lubars commented on August 28, 2024

Also effective:

String.format("tee %s", SSH.escape(file_name))

This has the advantage that you can prepend sudo if desired.

from jcabi-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.