Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

In first exemple, with exec, on stream.on: console.log(data.ToString), i do not have data" #110

Closed
OsvaldoTCF opened this Issue · 1 comment

2 participants

@OsvaldoTCF

c.exec('wstalist | grep last', function(err, stream)

Two codes:

With this, i have data:
stream.on('data', function(data, extended) {
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ')+data);
console.log('<<< data >>>');
});

With this code, i do not have data :
stream.on('data', function(data, extended) {
console.log('<<< data >>>');
console.log(data.ToString);
});

=====================
With this code:
stream.on('data', function(data, extended) {
console.log('<<< data >>>');
console.log(data.ToString);
});

I have this, no data:
DEBUG: Parser: STATE_INIT
DEBUG: Parser: STATE_GREETING
DEBUG: Parser: STATE_HEADER
DEBUG: Connection: Server ident: 'SSH-2.0-dropbear_0.51'
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:348,padLen:4,remainLen:344
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: KEXINIT
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Connection: Sent KEXINIT
DEBUG: Connection: Comparing KEXInits...
DEBUG: (local) Server->Client ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Server->Client ciphers: aes128-cbc,3des-cbc,aes256-cbc,twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc
DEBUG: Connection: Server->Client Cipher: aes256-cbc
DEBUG: (local) Client->Server ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Client->Server ciphers: aes128-cbc,3des-cbc,aes256-cbc,twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc
DEBUG: Connection: Client->Server Cipher: aes256-cbc
DEBUG: (local) KEX algorithms: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG: (remote) KEX algorithms: diffie-hellman-group1-sha1
DEBUG: Connection: KEX: diffie-hellman-group1-sha1
DEBUG: (local) Client->Server HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Client->Server HMAC algorithms: hmac-sha1-96,hmac-sha1,hmac-md5
DEBUG: Connection: Client->Server HMAC: hmac-md5
DEBUG: (local) Server->Client HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Server->Client HMAC algorithms: hmac-sha1-96,hmac-sha1,hmac-md5
DEBUG: Connection: Server->Client HMAC: hmac-md5
DEBUG: (local) Client->Server compression algorithms: none
DEBUG: (remote) Client->Server compression algorithms: none
DEBUG: Connection: Client->Server Compression: none
DEBUG: (local) Server->Client compression algorithms: none
DEBUG: (remote) Server->Client compression algorithms: none
DEBUG: Connection: Server->Client Compression: none
DEBUG: (local) Host key formats: ssh-rsa,ssh-dss
DEBUG: (remote) Host key formats: ssh-rsa,ssh-dss
DEBUG: Connection: Host key format: ssh-rsa
DEBUG: Connection: Sent KEXDH_INIT
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:444,padLen:4,remainLen:440
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: KEXDH_REPLY
DEBUG: Connection: Checking host key format
DEBUG: Connection: Checking signature format
DEBUG: Connection: Verifying signature
DEBUG: Connection: Sent NEWKEYS
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:12,padLen:10,remainLen:8
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: NEWKEYS
DEBUG: Connection: Sent SERVICE_REQUEST
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: SERVICE_ACCEPT
DEBUG: Connection: Sent USERAUTH_REQUEST (password)
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:10,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: USERAUTH_SUCCESS
Connection :: ready
DEBUG: Connection: Sent CHANNEL_OPEN
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_OPEN_CONFIRMATION
DEBUG: Channel: Sent CHANNEL_REQUEST (exec)
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_SUCCESS
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:860,padLen:12,remainLen:848
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_DATA
<<< data >>>
undefined
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_EOF
Stream :: EOF
DEBUG: Channel: Sent CLOSE
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:18,remainLen:32
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_REQUEST
Stream :: exit :: code: 0, signal: undefined
DEBUG: Connection: Sent DISCONNECT
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_CLOSE
Stream :: close
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
Connection :: end
Connection :: close

With this:
stream.on('data', function(data, extended) {
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ')+data);
console.log('<<< data >>>');
});

I have this result, with data:
DEBUG: Parser: STATE_INIT
DEBUG: Parser: STATE_GREETING
DEBUG: Parser: STATE_HEADER
DEBUG: Connection: Server ident: 'SSH-2.0-dropbear_0.51'
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:348,padLen:4,remainLen:344
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: KEXINIT
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Connection: Sent KEXINIT
DEBUG: Connection: Comparing KEXInits...
DEBUG: (local) Server->Client ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Server->Client ciphers: aes128-cbc,3des-cbc,aes256-cbc,twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc
DEBUG: Connection: Server->Client Cipher: aes256-cbc
DEBUG: (local) Client->Server ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Client->Server ciphers: aes128-cbc,3des-cbc,aes256-cbc,twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc
DEBUG: Connection: Client->Server Cipher: aes256-cbc
DEBUG: (local) KEX algorithms: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG: (remote) KEX algorithms: diffie-hellman-group1-sha1
DEBUG: Connection: KEX: diffie-hellman-group1-sha1
DEBUG: (local) Client->Server HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Client->Server HMAC algorithms: hmac-sha1-96,hmac-sha1,hmac-md5
DEBUG: Connection: Client->Server HMAC: hmac-md5
DEBUG: (local) Server->Client HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Server->Client HMAC algorithms: hmac-sha1-96,hmac-sha1,hmac-md5
DEBUG: Connection: Server->Client HMAC: hmac-md5
DEBUG: (local) Client->Server compression algorithms: none
DEBUG: (remote) Client->Server compression algorithms: none
DEBUG: Connection: Client->Server Compression: none
DEBUG: (local) Server->Client compression algorithms: none
DEBUG: (remote) Server->Client compression algorithms: none
DEBUG: Connection: Server->Client Compression: none
DEBUG: (local) Host key formats: ssh-rsa,ssh-dss
DEBUG: (remote) Host key formats: ssh-rsa,ssh-dss
DEBUG: Connection: Host key format: ssh-rsa
DEBUG: Connection: Sent KEXDH_INIT
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:444,padLen:4,remainLen:440
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: KEXDH_REPLY
DEBUG: Connection: Checking host key format
DEBUG: Connection: Checking signature format
DEBUG: Connection: Verifying signature
DEBUG: Connection: Sent NEWKEYS
DEBUG: Parser: STATE_PACKETBEFORE (expecting 8)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: pktLen:12,padLen:10,remainLen:8
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: NEWKEYS
DEBUG: Connection: Sent SERVICE_REQUEST
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: SERVICE_ACCEPT
DEBUG: Connection: Sent USERAUTH_REQUEST (password)
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:10,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: USERAUTH_SUCCESS
Connection :: ready
DEBUG: Connection: Sent CHANNEL_OPEN
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_OPEN_CONFIRMATION
DEBUG: Channel: Sent CHANNEL_REQUEST (exec)
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_SUCCESS
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:860,padLen:12,remainLen:848
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_DATA
STDOUT: "lastip" : "172.16.196.188",
"lastip" : "172.16.196.104",
"lastip" : "172.16.196.28",
"lastip" : "172.16.196.13",
"lastip" : "172.16.196.249",
"lastip" : "0.0.0.0",
"lastip" : "172.16.196.27",
"lastip" : "0.0.0.0",
"lastip" : "0.0.0.0",
"lastip" : "172.16.196.115",
"lastip" : "172.16.196.171",
"lastip" : "172.16.196.155",
"lastip" : "172.16.196.122",
"lastip" : "172.16.196.99",
"lastip" : "172.16.196.54",
"lastip" : "172.16.196.253",
"lastip" : "172.16.196.224",
"lastip" : "172.16.196.152",
"lastip" : "172.16.196.157",
"lastip" : "172.16.196.225",
"lastip" : "172.16.196.133",
"lastip" : "169.254.70.12",
"lastip" : "172.16.196.203",
"lastip" : "172.16.196.9",
"lastip" : "172.16.196.214",
"lastip" : "172.16.196.147",
"lastip" : "172.16.196.79",
"lastip" : "172.16.196.248",

<<< data >>>
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_EOF
Stream :: EOF
DEBUG: Channel: Sent CLOSE
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:18,remainLen:32
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_REQUEST
Stream :: exit :: code: 0, signal: undefined
DEBUG: Connection: Sent DISCONNECT
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
DEBUG: Parser: STATE_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:12,padLen:6,remainLen:0
DEBUG: Parser: STATE_PACKETDATA
DEBUG: Parser: hmacSize:16
DEBUG: Parser: STATE_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_CLOSE
Stream :: close
DEBUG: Parser: STATE_PACKETBEFORE (expecting 16)
Connection :: end
Connection :: close

@mscdex
Owner

This:

console.log(data.ToString);

should be this:

console.log(data.toString());
@mscdex mscdex closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.