hi , i am a still beginner in unix and specially in ftp i've written this script but my admin asked me that he don't want to see in my ftp neither user neither password , so i've created .netrc file where in it i've put machine name , user and pass but still included in my script , so if someone can see it to tell me who to remove my user and pass from the script to use it wthout them just automate it
the script is :
cd /tmp/FCDR_TEST
i=1
while [ $i -le 10 ]
do
touch file$i
i=`expr $i + 1`
done
HOST='x.y.z.u'
USER='user'
PASSWD='jajaja'
/usr/bin/ftp -i -n $HOST << EOF
quote USER $USER
quote PASS $PASSWD
cd /tmp/FCDR_TEST
lcd /export/home/user/tmp
mget file*
bye
EOF
rm /tmp/FCDR_TEST/file*
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
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
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
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
local directory now /export/home/sfrangie/tmp
Not connected.
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 :
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 :
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.
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