Automation of ftp connection. where to input username and password?

I want to automate the script to input name and password when started FTP server but could not figure out where to redirect input of username and password.


  1. For automating login and file transfer via ftp command you have to set some additional flags while calling it apart from the usual ftp hostname port

    • Usually the prompt asks us to enter the username followed by the password, this behaviour has to be turned off. We’ll have to login using an ftp command.

    • To output all responses from the server and statistics like transfer speed for easier debugging, enable verbose

  2. After we enter the ftp command with hostname, port and appropriate flags, use ? to list out the available commands

  3. We haven’t logged into the QBox Server yet, so glance through the list of commands and select the appropriate command after consulting with Google (of course, only in case you don’t know the command :slight_smile: )

  4. Login using the command along with its favourite arguments. You’ll get a 230 Login successful indicating Login.

  5. Now, you can add all the other commands we usually do for file transfer

  6. Now comes the hard part, you’ll have to use heredoc to add all the commands starting with login(4) to completing the transfer and exiting(5) line by line to the output terminal of ftp command(1)

Hope it helps :slight_smile:

1 Like

Thanks for reply! Looks like there is many thing to do to achieve this.

Wow that was a good explanation. @vipulkrishna A google search returned this -

Not really @vipulkrishna, this all boils down to 8 lines of code for downloading and uploading one file. But, extremely comes in handy as we use it umpteen number of times for Module 5 and Module 6 cumulatively.

Other modifications/things you can automate are:

  1. Different scripts/Common script that takes a flag(--upload/--download) and the filename to transfer

  2. Create files and folders, set permissions and ownerships for data we don’t store in the workspace

  3. To clean all ftp related processes, because sometimes things terminate abruptly and we need to find the processes manually and kill them

After all this you can just run a couple of scripts(and sometimes enter password :slight_smile:) for all(most) the purposes