How to use the password in my script?

Hi Gurus,

I have an issue to use the passwd in my script.

in the script, I need log into the ftp server and get file.

I put the user name and password in my script, but each time when I run the script, it still ask the password.

I am wondering, is there any way I can put the password in the script and let it run automatically.

My OS is Linux

thanks in advance.

Create a ${HOME}/.netrc file with permissions of 0400..

Put the following line in the file..
machine your-server-name login your-server-login password your-server-password

But really FTP is not very secure... You should consider re-writing with SSH/SFTP/SCP
with private/public keys for authentication..

1 Like

For ftp you could use ~/.netrc, with syntax like this:

machine hostname.com
        login username
        password password

For sftp, which is not the same thing at all, you would use ssh keys.

1 Like

Thanks both of you.

I will try the why you guys suggested.