How to stop asking password while running shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to stop asking password while running shell script?
# 1  
Old 11-11-2008
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
# 2  
Old 11-11-2008
Quote:
Originally Posted by govindts
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...

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

Code:
machine example.com
login someone
password my_password

See the ftp man page for more information.


Please put code inside [code] tags:
Quote:
Code:
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


For dummy domain names, please use example.com (or .net, .org, etc.).
Quote:
Code:
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

# 3  
Old 11-11-2008
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..
# 4  
Old 11-12-2008
Quote:
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.
# 5  
Old 11-12-2008
Okay. I am hoping, some one could explin in this forums...
# 6  
Old 11-12-2008
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Password in shell script for apps stop

Hi folks, I am running a shell script it asks for username and password to stop some service, I need to write some script that it will read username and password from my shell script and then sucessfully stop services without prompting username/password query. (13 Replies)
Discussion started by: learnbash
13 Replies

2. Shell Programming and Scripting

Need help in running a script continuously non stop

Hi, I am running a schedular script which will check for a specific time and do the job. I wanted to run this continuously. Meaning even after the if condition is true and it executes the job, it should start running again non stop. I am using below script #!/bin/sh start: while true do... (10 Replies)
Discussion started by: sandeepcm
10 Replies

3. Shell Programming and Scripting

Stop! (the countdown!) :-) shell script help

Hi guys, I've found two nifty little scripts on these forums one which detects if the F5 key has been pressed: #/bin/sh _key() { local kp ESC=$'\e' _KEY= read -d '' -sn1 _KEY case $_KEY in "$ESC") while read -d '' -sn1 -t1 kp do _KEY=$_KEY$kp ... (0 Replies)
Discussion started by: rich@ardz
0 Replies

4. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

5. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

6. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

7. Shell Programming and Scripting

How to stop the script which is running in background

Hi I have a script, which i ran in background, can someone please help in stopping this. i gave this command: ksh abc.ksh & this script sends me a mail every 30 seconds. i have deleted the script but still i am getting the mails. can some one please help me stopping dese. ... (3 Replies)
Discussion started by: Prateek007
3 Replies

8. UNIX for Dummies Questions & Answers

Stop a shell script

Hi, I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following: mike=1 if ; then STOP THE SCRIPT fi (3 Replies)
Discussion started by: msb65
3 Replies

9. Shell Programming and Scripting

stop Prstat using shell script

How to stop the Prstat using shell script ? because after i run the below script the thing seems to be always in loop and cannot get out till i ctrl + c, is there anything that i can add in the script to make it terminate ? <code> #!/bin/sh prstat -Tc -u testing > testing.txt </code> ... (19 Replies)
Discussion started by: filthymonk
19 Replies

10. UNIX for Dummies Questions & Answers

Running file sql from shell without capture the password

Dear All I have file a.sql, let's say the content is: _________________________________ select * from dual; exit; _________________________________ and I have shell script a.sh, the content is: _________________________________ ORACLE_SID=testing; export ORACLE_SID... (0 Replies)
Discussion started by: Aditya Purwanto
0 Replies
Login or Register to Ask a Question