progress bar in ftp script

dear all ,

i made script to transfer data through the FTP but i need to add something if you can help me i want in the output message like progress bar

|||||||||||||||||||||||||| 30%

to know when it will finish

This is not possible (not "out of the box", that is), because to the shell script starting the ftp job "ftp" is just another command. To create a progress bar the program "ftp" would either have to have such a feature (which isn't the case) or it would have to give back control to the calling script regularly so that this script could update the progress bar. This is also not possible.

You can consider using "scp" (secure copy) instead of ftp, which is recommended anyhow. It doesn't send clear-text passwords over the net (like ftp) and it encrypts the files transferred too, so they can't be snooped by a thrid party. "scp" features a progress bar too, so it would solve your problem as a side effect.

The other possible solution is very tricky and won't always work: if the ftp server tells you the size of the file to be transferred (not all do) you can issue the ftp process as background process, set up a loop in the foreground, observe the size of the already transferred file in regular intervals and compute the percentage from there. Then use "printf" to write the progress bar to the terminal.

I hope this helps.

bakunin

thanks a lot ok i will use scp but i have a problem with scp that i want to put user name and password and scp need the password to be writen

Here is the first google hit for passwordless ssh for you. This is how you configure automatic login in ssh, scp, and sftp. It's much safer than storing passwords.