Comments (5)
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.
ok, thank you.
from jcabi-ssh.
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.
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.
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)
- jcabi-aspects does not work
- update jsch HOT 2
- Dependency Dashboard
- Tarea_refactoring
- Tarea Refactoring1
- going through a jump server
- Turn off logging ?? HOT 5
- Logs has the risk of exposing sensitive information HOT 2
- Any chance to deploy it with jlink? HOT 2
- class SSH.session create too many temp file HOT 6
- Upgrade the cactoos dependency to the latest version as they are incompatible now HOT 2
- How to get it working on Java 11? HOT 5
- How to send several commands one after the other HOT 4
- springboot HOT 1
- fresh release HOT 3
- Ssh doesn't disconnect after the process goes to background HOT 12
- extra config for JSch session HOT 3
- com.jcraft.jsch.JSchException: socket is not established HOT 16
- Replace JSCH implementation HOT 5
- scp capabilities
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 jcabi-ssh.