0

I have a functioning, automated FTP script that I have previously verified as functional, but as of today, when running the script, the machine is recognizing the username input, but not the password, giving the following output (reduced to show problem only):

331 User name okay, need password.

530 not logged in

For some reason, it's reading the command to pipe the username, but not the password, even though they are exactly the same, and in consecutive lines.

If it's worth anything, the file is saved on the machine's desktop, and I usually navigate to the directory through cd ~/Desktop

Here's the code, any help at all is appreciated:

#!/bin/bash

HOST=example.mydomain.com  
USER=user           
PASS=pass          

cd source/directory
ftp -inv $HOST << EOF
quote USER $USER
quote PASS $PASS
cd target/directory
put sampleFile.gz

exit

EOF

EDIT: I have seperately tried to ftp manually through ftp example.mydomain.com and the credentials are still correct.

4
  • When you say you've tried this manually, did you do the same sequence of commands, by copying and pasting from the script for example? Did you recently update your password, or did the FTP server or client software get changed/updated? Note too that you should generally use lower-case variable names. There may well already be a USER environment variable that you are overwriting with your script. Some shells also has a HOST variable (not bash, but zsh has). This is unlikely the cause of your issue unless ftp uses those environment variables internally (I don't think it does).
    – Kusalananda
    Jan 3, 2020 at 17:39
  • By testing manually, I mean that I tested the credentials to verify if they were still correct, which they happen to be. The rest of the code appears to be functional as the script still attempts to execute it line-by-line, but as I am not "logged in", it returns 530 Not logged in and Passive mode refused for those. To my knowledge, the server/client both have not been updated. I have also tested the variables in different cases and the issue is still present. Jan 3, 2020 at 17:46
  • There may have been a change in the firewall rules on the server? Try using active mode instead. Some FTP clients have a flag for this, on my system it's -A but you should check your manual. If active mode works, then I still wouldn't see that as a "solution" but rather as a "workaround".
    – Kusalananda
    Jan 3, 2020 at 17:49
  • This issue is still persisting - what confuses me the most is that there were virtually no changes to anything in the code/network and it's unable to recognize the password piping. It's a real head-scratcher. Jan 3, 2020 at 17:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.