Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

. netrc file and FTP

Status
Not open for further replies.

lweng

Technical User
May 18, 2001
113
US
In the .netrc file how do we give the ftp server details such as user name and password if for the same ftp server more than one user information is required to be populated and accessed.
for eg if i give

machine 121.12.12.12 USER sss1 paeeword ddd1
mcdefinit
cd /d/d

machine 121.12.12.12 USER sss2 paeeword ddd2
mcdefinit
cd /d/s

How can i access the information in a shell program so that the system will login to the remote server based on the user name specified in the script because if i do not specify any user it will take the first user and automatically login
If i specify any username it will not look into the .netrc file
and prompt for password
what can be done to solve this issue
 
if security is not a issue I think you can use a very simple shell script, example to do a "ls -l" in user home directory.

#!/bin/sh
#ftp.sh

HOST=$1
USER=$2
PASSWORD=$3
MODE=binary
CD=$HOME
COMMAND="ls -l"

LOG_IN="open $HOST\nuser $USER $PASSWORD\n"

echo "${LOG_IN}${MODE}\ncd ${CD}\n${COMMAND}" | ftp -v -n
#

# ftp.sh myhost myuser mypass

... change commands acording your needs and add some error check...

Hope this helps,

Regards,

Carlos Almeida


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top