the function you pass to an EventEmitter#on is not a callback, it is an event listener.
the difference, is that callbacks are called exactly once, and the first argument reserved for an error parameter. an event listener, on the other hand, may be called 0 or more times, until you remove the listener, or when ever the event emitter has finished. and there is no error paramater (the event emitter should just emit a separate 'error' event) On Tue, Jul 31, 2012 at 3:20 AM, carlton <carltondick...@gmail.com> wrote: > I've tried a range of ftp modules, some are out of date and don't work with > the latest version of Node and other don't seem to support SFTP and the fact > I need to use a key to connect to my server. > > Do you know much about child_process etc...I'm wondering if the 'fork' > functionality is what I should be using. > > i.e. I connect to the SFTP with the parent process and form child to make my > other commands and also create new event listeners for when the data > returns. > > I may also give this a chance https://github.com/sergi/jsftp as I tried it > a while ago only to get error "FTP is not defined" which was odd as the > module seems to be required without an error > > > On Monday, 30 July 2012 15:11:34 UTC+1, Roly Fentanes wrote: >> >> Why not try using one of the ftp modules? >> >> http://toolbox.no.de/search?q=ftp >> >> On Monday, July 30, 2012 4:01:43 AM UTC-7, carlton wrote: >>> >>> Hi there, >>> >>> I am trying to implent a nodejs script that connects to one of our >>> servers using sftp. >>> >>> So far I can connect using child process and spawning a command such >>> as... >>> >>> sftp -o Port=22-o PasswordAuthentication=no-o >>> UserKnownHostsFile=/home/carlton/.ssh/known_hosts-o >>> IdentityFile=private_key-o StrictHostKeyChecking=no-o >>> BatchMode=nodeploy@46.x.x.x:/home/carlton/to_process >>> >>> Now this is the part that has me confused... >>> >>> I then need to execute commands on the ftp server (e.g. list files, >>> rename files) so I listen to the 'data' event.... >>> >>> sftp.stdout.on('data', function (data) { >>> console.log('stdout: ' + data); >>> >>> sftp.stdin.write("ls -l\r\n"); >>> >>> sftp.stdout.on('data', function(data){ >>> console.log('File list:', data.toString()); >>> >>> // Parse file names here >>> >>> sftp.stdin.write("rename >>> /home/carlton/FTP_test/to_process/old.php /home/ carlton >>> /FTP_test/processed/new.php\n"); >>> }); >>> }); >>> >>> Is this the correct way to structure things (i.e. creatiung event >>> listener again for the 'data' event within the callback of the previous >>> 'data' event listener)? >>> I found it hard to find any examples similar to what I need to do which >>> made me think I haven't built this as it should have been. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en