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.
For automating login and file transfer via
ftpcommand 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
After we enter the
ftpcommand with hostname, port and appropriate flags, use
?to list out the available commands
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 )
Login using the command along with its favourite arguments. You’ll get a
230 Login successfulindicating Login.
Now, you can add all the other commands we usually do for file transfer
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
Hope it helps
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 - https://blog.eduonix.com/shell-scripting/how-to-automate-ftp-transfers-in-linux-shell-scripting/
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:
Different scripts/Common script that takes a flag(
--download) and the filename to transfer
Create files and folders, set permissions and ownerships for data we don’t store in the workspace
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 ) for all(most) the purposes