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
# 8  
Old 09-15-2011
can you post your latest script
# 9  
Old 09-15-2011
r u trying to tell me to use macdef in my .netrc file ? or another way if that so can u please show me how to , tx itkamaraj

---------- Post updated at 01:08 PM ---------- Previous update was at 01:07 PM ----------

Code:
1  cd /tmp/FCDR_TEST
     2  i=1
     3  while [ $i -le 10 ]
     4  do
     5  touch file$i
     6  i=`expr $i + 1`
     7  done
     8
     9  #HOST='1.1.1.1'    
    10  #USER='sfrangie'
    11  #PASSWD='sdsd'
    12
    13  /usr/bin/ftp -i -n $HOST << EOF
    14  #quote USER $USER
    15  #quote PASS $PASSWD
    16  cd /tmp/FCDR_TEST
    17  lcd /export/home/sfrangie/tmp
    18  mget file*
    19  bye
    20  EOF
    21  rm /tmp/FCDR_TEST/file*

---------- Post updated at 01:09 PM ---------- Previous update was at 01:08 PM ----------

of course the # in front of HOST n USER n pass is removed Smilie

Last edited by pludi; 09-15-2011 at 05:19 AM..
# 10  
Old 09-15-2011
is .netrc script is under the home directory of the script owner ?

From the command prompt, just try

Code:
 
ftp $HOST

# 11  
Old 09-15-2011
yes it is under the same home directory , which is me , n when ftp $HOST it showed me ftp> but anything typed is to be said not connected , all what i want to know is how to automoate my scripts without putting in it the user name and the password :S
# 12  
Old 09-15-2011
For future reference:
  • Please use a descriptive subject text when posting questions, so that users with similar problems can find the thread more easily
  • Please write in complete English instead of texting slang. There's enough space for a post to include complete words like "are", "you", or "and"
  • Finally, when posting scripts, command lines, ... use [CODE] tags to enhance readability and preserve formatting.
# 13  
Old 09-15-2011
can you put the hostname,username, password in this order in .netrc file and give a try

machine fullmachine-name login loginID password passwd
# 14  
Old 09-15-2011
so u are telling me to remove the password and user name from my scripts and just putting them in .netrc with chmod to 600 and try my scripts , if that my script will become


Code:
Code:
     1  cd /tmp/FCDR_TEST     2  i=1     3  while [ $i -le 10 ]     4  do     5  touch file$i     6  i=`expr $i + 1`     7  done     8     9          10      11      12    13  /usr/bin/ftp -i -n $HOST << EOF    14  cd /tmp/FCDR_TEST    15  lcd /export/home/sfrangie/tmp    16  mget file*    17  bye    18  EOF    19  rm /tmp/FCDR_TEST/file*

and the .netrc file is : machine x.x.x.x login sfrangie password sarkis1sa_Z2

if that it is giving me as response :
Not connected.
Local directory now /export/home/sfrangie/tmp
Not connected.

---------- Post updated at 01:44 PM ---------- Previous update was at 01:43 PM ----------

so u are telling me to remove the password and user name from my scripts and just putting them in .netrc with chmod to 600 and try my scripts , if that my script will become

Code:
cd /tmp/FCDR_TEST
i=1
while [ $i -le 10 ]
do
touch file$i
i=`expr $i + 1`
done

/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*



it is giving me not connected
Code:
local directory now /export/home/sfrangie/tmp
Not connected.


Last edited by pludi; 09-15-2011 at 06:12 AM..
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