Node.js + SCP + stdin.write on Ubuntu 9

I have a doubtful pleasure of using Ubuntu 9 (no choice) and i installed Node.js on it.

I want to use SCP (for copying files through ssh). So i do a little bit of node-magic:

scpHandler = require('child_process').spawn('scp',['root@192.168.2.16:/user/MyDocs/smsOut.txt', 'smsOut2.txt']);

And then there appears to be a problem - ssh needs a password, i cannot omit that problem by authorization_keys cause they happen not to work on this particular device (Maemo).

So i thought - OK, i will just use stream writing and it will solve everything:

scpHandler.stdout.on('data', function(data){
            console.log(data);
            scpHandler.stdin.write('password');
            scpHandler.stdin.write('String.fromCharCode(13)');
    });

It should reflect writing password after scp displays any message (and it asks for password right away) but, as You can all guess by now, something goes wrong and NOTHING HAPPENS. There should be some data displayed after succesful/unsuccesful transfer when sc gets the right password, but it still waits for password... please help, any ideas what is wrong?

Problem solved: using setTimeout for waiting and pty.js for deceiving terminal seems to be ok in this case.