Automated FTP without plaintext user/password in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automated FTP without plaintext user/password in script
# 15  
Old 09-15-2011
1) your .netrc should be under the home directory of the user (who owns the script)
2) your .netrc file should be like below.

Code:
$ cat .netrc
machine abcd.eft.com login username password xyz

3) it should have 600 permission

4) once above steps are taken care. try the below command in the command prompt and check whether it works or not

Code:
 
ftp abcd.eft.com

# 16  
Old 09-15-2011
it worked :d , as ftp machinename ,,
my question is how to include this ftp in my script without mentioning the user and the password in the script so it would be like :

Code:
cd /tmp/FCDR_TEST
i=1
while [ $i -le 10 ]
do
touch file$i
i=`expr $i + 1`
done
HOST='x.x.x.x'
 
/usr/bin/ftp -i -n $HOST
cd /tmp/FCDR_TEST
lcd /export/home/sfrangie/tmp
mget file*
bye
EOF
rm /tmp/FCDR_TEST/file*



it is giving me now an answer :
Code:
Please login with USER and PASS.
Local directory now /export/home/sfrangie/tmp
Please login with USER and PASS.
Please login with USER and PASS.


Last edited by pludi; 09-15-2011 at 06:13 AM..
# 17  
Old 09-15-2011
where is your <<EOF ?

Please use the [CODE] tags
# 18  
Old 09-15-2011
Code:
cd /tmp/FCDR_TEST
i=1
while [ $i -le 10 ]
do
touch file$i
i=`expr $i + 1`
done
HOST='x.x.x.x'

/usr/bin/ftp -i -n $HOST << EOF
cd /tmp/FCDR_TEST
lcd /export/home/sfrangie/tmp
mget file*
bye
EOF
rm /tmp/FCDR_TEST/file*


the answer for my scripts is
Please login with USER and PASS.
Local directory now /export/home/sfrangie/tmp
Please login with USER and PASS.
Please login with USER and PASS.


so how will i include my .netrc so the ftp command in my script will read the username and the password withput putting them in my script
# 19  
Old 09-15-2011
Code:
cd /tmp/FCDR_TEST
i=1
while [ $i -le 10 ]
do
touch file$i
i=`expr $i + 1`
done
HOST='x.x.x.x'

/usr/bin/ftp -i $HOST <<-EOF
cd /tmp/FCDR_TEST
lcd /export/home/sfrangie/tmp
mget file*
bye
EOF
rm /tmp/FCDR_TEST/file*

# 20  
Old 09-15-2011
big thanks itkamaraj Smilie now i shall call u my adm Smilie really was it from that little option -n , tx a lot again hope didn't make u tired withe me Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Encrypt Plaintext Password?

How do I encrypt a plaintext password that I need hardcoded in a bash script? (3 Replies)
Discussion started by: wyclef
3 Replies

2. Shell Programming and Scripting

Deleting local server file from automated FTP script

Hi, I want to delete a file on the local server, while connected to remote server through FTP. I am using the below code for this $FTP_CMD -v -n $HOST <<*! >> $LOGFILE 2>&1 user $USER $PASSWORD cd $DIR ... (11 Replies)
Discussion started by: jhilmil
11 Replies

3. Shell Programming and Scripting

Automated script to look for files in FTP Server location.

suppose one file comes in one sever location on MOnday.we have to write a script to automatically get that files and put it in different server location. ---------- Post updated at 10:28 AM ---------- Previous update was at 10:27 AM ---------- Please help me on this (2 Replies)
Discussion started by: sonam273
2 Replies

4. UNIX for Advanced & Expert Users

Automated SCP script passing password to preserve source file timestamp

Hi My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file. By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Discussion started by: skumar75
1 Replies

5. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

6. Shell Programming and Scripting

Help needed with automated FTP script

Hi, Ok, i'm trying to automate sending a DB backup from a linux box to a remote Windows PC via FTP. I can connect, send the file and create a folder, however I require that the backups be differentiated by date. Here is what my script looks like: open *.*.*.* user username password lcd... (4 Replies)
Discussion started by: leimrod
4 Replies

7. Shell Programming and Scripting

ftp and user/password

I know the typical way to script automate an ftp session is to pass all of the commands to ftp, with something 'like' the following: echo USER $user echo PASS $pass My question concerns other methods or tricks people have used so that the username and ESPECIALLY the password are... (7 Replies)
Discussion started by: joeyg
7 Replies

8. UNIX for Advanced & Expert Users

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

9. Programming

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

10. Shell Programming and Scripting

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies
Login or Register to Ask a Question