How to stop asking password while running shell script?

Hello,

I am ftping the file from one unix box to another box. This script works fine. Only problem here is, it is asking the password when ftp the file. How can i stop that. I am providing the password inside the shell script. But it is not accepting this. I need to put this script in crontab. So i wanted to take the passwod from shell script file.. Any help is greatly appreciated...

export ORACLE_HOME=/usr/app/oracle/product/9.2.0
export WORKING_DIR=/home/odsapp/apps/CTSI
export FTP_TO=${WORKING_DIR}/CTSI_FILES
export FTP_FROM=xx.xx.com
export FTP_USER=xxx
export FTP_USER_PASSWD=yyy
cd ${FTP_TO}
ftp -dni << EOT
open $FTP_FROM
user $FTP_USER $FTP_USER_PASSW
cd /home/ftp/download
binary
get test.zip
bye
EOT

Put the login information in a .netrc file, e.g.:

machine example.com
login someone
password my_password

See the ftp man page for more information.

Please put code inside

 tags:


export ORACLE_HOME=/usr/app/oracle/product/9.2.0
export WORKING_DIR=/home/odsapp/apps/CTSI
export FTP_TO=${WORKING_DIR}/CTSI_FILES
export FTP_FROM=xx.xx.com

[/quote]

[indent]
For dummy domain names, please use example.com (or .net, .org, etc.).

Thank you very much and my problem resolved after creating entry in .netrc.
One question... Even after creating the entry in .netrc, i need to specify password in shell script. So what is the purpose the .netrc file now? I thought, we don't need to specify the password when we have entry in .netrc file. But my assumption is wrong.
So we are not hiding the password in shell script. What is use of .netrc file here. Can you please help me understand..

I too had the same question few days back.
Googled it, but dint find anything useful.

Okay. I am hoping, some one could explin in this forums...

A password in .netrc works fine in general. You may have a broken ftp server or maybe the author of the ftp server decided he doesn't like passwords in files.

I'm sure you already checked either the .netrc man page on your own system or you found one of the hundreds of manpages on the web like this: netrc(4) (man Pages(4): File Formats) - Sun Microsystems which clearly state:

"If this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process. Note: if this token is present in the .netrc file, ftp will abort the autologin process if the .netrc is readable by anyone besides the user."

and thus we can discount the possibility that you have the wrong permissions set on your .netrc file. Right?