The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
stop users from running 'history -c' in Linux xander Shell Programming and Scripting 3 09-17-2008 08:07 AM
Stop a shell script msb65 UNIX for Dummies Questions & Answers 3 09-04-2008 09:28 AM
Running from Shell Vs running from RC script vickylife SUN Solaris 2 07-31-2008 09:01 AM
stop Prstat using shell script filthymonk Shell Programming and Scripting 19 05-23-2007 05:24 AM
Running file sql from shell without capture the password Aditya Purwanto UNIX for Dummies Questions & Answers 0 08-31-2006 12:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-11-2008
govindts govindts is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 63
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 (permalink)  
Old 11-11-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by govindts View Post
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 (permalink)  
Old 11-11-2008
govindts govindts is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 63
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 (permalink)  
Old 11-12-2008
cool.aquarian cool.aquarian is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 4
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 (permalink)  
Old 11-12-2008
govindts govindts is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 63
Okay. I am hoping, some one could explin in this forums...
  #6 (permalink)  
Old 11-12-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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?
Closed Thread

Bookmarks

Tags
unix download

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0