Comments (4)
It's fairly similar to exec() in that you pass in a callback and get an error or a ChannelStream object. If there was no error, you can read or write to the stream as if it were a terminal. As you can see in the documentation, you can also pass in an object before the callback that describes the pty (dimensions and terminal type) to use during the shell session, however there are sensible defaults in place so you probably don't have to worry about this.
Simplest example:
// inside Connection 'ready' event handler ....
c.shell(function(err, stream) {
if (err) throw err;
stream.on('data', function(data, extended) {
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ')
+ data);
});
stream.on('close', function() {
console.log('Stream :: close');
});
stream.write('ls -l\n');
});
from ssh2.
worked thanks.
from ssh2.
Could you put this example in the readme
from ssh2.
@andrewm-mediasuite added in 1676cfa.
from ssh2.
Related Issues (20)
- Unknown Error during Handshake HOT 1
- `Handshake failed: no matching host key format` on `ssh-keyscan` HOT 2
- Difference between forwardout and manual net connect HOT 1
- [HELP] How can i convert private key .ppk to .pem. HOT 2
- Cyberark HOT 1
- Output cut off in the middle during a stream HOT 1
- Command not found when I use ssh2 HOT 2
- forwardOut method local port forward doesn't work? HOT 2
- how to choose between shell or exec function ? HOT 3
- How to pass parameters to ssh2? HOT 1
- ssh key
- Terrapin advice HOT 2
- Vulnerability CVE-2023-48795 Reported: Prefix Truncation Attack, Fix Requested HOT 2
- Pure JS fallback when WASM is not available
- Can't connect "ignoring handled error" HOT 9
- any method to execute command after ssh connected. HOT 10
- Get remote port forwarding -R local port HOT 2
- Question: HTTPSAgent reuse HOT 3
- Execute ssh command inside a "for of" HOT 7
- Test code should be excluded from the published package HOT 1
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 ssh2.