Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output from client.shell returns [object Object] when toString() is called on it #34

Closed
op1ekun opened this issue Sep 21, 2015 · 3 comments

Comments

@op1ekun
Copy link

op1ekun commented Sep 21, 2015

Hi guys, I run into a strange issue:

client.shell(serial, 'ifconfig wlan0', function adbCommandCb(err, output) {
    console.log(output.toString('utf-8'));
}

The console.log produces [object Object].
I have already tried using just plain .toString(), but the result is the same.

I will try Promise version any (it fits in the code better than the callback one).

Version of adbkit: 2.3.1
Node: 0.10.40
System: Windows Server 2012 R2

Thanks!

@sorccu
Copy link
Member

sorccu commented Sep 21, 2015

That's correct behavior. The shell() command supports long-running commands such as while loops and logcat, so it needs to stream the output before it finishes. See https://github.com/openstf/adbkit#example for example usage.

@sorccu sorccu closed this as completed Sep 21, 2015
@op1ekun
Copy link
Author

op1ekun commented Sep 21, 2015

Read test failed...
I completely missed it.
Thanks!

@op1ekun
Copy link
Author

op1ekun commented Sep 21, 2015

Actually now I know why I got confused.

The docs for client.shell say:
output - A Buffer containing all the output. Call output.toString('utf-8') to get a readable String from it.

However output here is a Stream. To get the Buffer you either have to listen to Stream events or use your util.readAll.

I was trying hard to read the Buffer which wasn't there yet ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants