sergi/jsftp

chmod() produces Error: 500 Unknown command

Closed this issue · 5 comments

Code that's run:

ftp.raw.chmod('664', 'test.jpg', function(err, data) {
    if (err) return console.error(err);

    console.log(data.text); // Show the FTP response text to the user
    console.log(data.code); // Show the FTP response code to the user
});

Debug output:

DEBUG:  user_command
"chmod 664 test.jpg"
DEBUG:  response
{
  "code": 500,
  "text": "500 Unknown command.",
  "isMark": false,
  "isError": true
}
{ [Error: 500 Unknown command.] code: 500 }

It suggest the correct command is executed (chmod 664 test.jpg), but fails to change the file permissions and produces Error 500.

Looks like your server doesn't recognize the CHMOD command. What server are you trying to connect to?

It's Rackspace cloud. I can chmod when I log in to the server with SSH.

SSH is not FTP. They have an FTP server that might not support or allow chmod through FTP. jsftp completes the action just fine, but your server returns a 500 error.

Got that, it looks like that indeed, but when I switched to "ftp" module (https://www.npmjs.org/package/ftp) instead, chmod started to work out fine, that's why I got suspicious. (My code is here: https://github.com/denizozger/Bird/blob/master/lib/ftp.js).

Interesting @denizozger. Just checking, could it be a problem with the path you are passing to the chmod command? I see that in your ftp module example you compose the string and in the example you posted above you directly put a file there. If that file was not in the root folder you would need to be in the right path to chmod it.