Hi,
I tried writing a script and there was a problem with SFTP part
can some one correct where is is the mistake
Enveronment file
#!/bin/bash
export HOST_NAME=<>
export USER_NAME=<>
export PASSWORD=<>
export SOURCE_PATH=/u03/informatica/current/server/infa_shared/TgtFiles/mfg
export LOCATION_PATH=/u03/informatica/current/server/infa_shared/TgtFiles/mfg
export LOGFILE_DIR=/u03/informatica/current/server/infa_shared/TgtFiles/mfg
Main Script is
#!/bin/bash
#########################
#MAIL SCRIPT
#########################
. /u03/informatica/.informatica.env
. /u03/informatica/current/server/infa_shared/ScriptFiles/mfg/oa3/CSSS_Etct_File_Tns.env
cd $SOURCE_PATH
echo '$SOURCE_PATH'
for i in DEES-* ; do
s=`echo $i | cut -d "-" -f3`
echo $s
result=$(grep -h $s $SOURCE_PATH/csss_file*.txt)
dest_path=`echo $result | cut -d "|" -f2`
echo $dest_path
sftp $Host_name << end_script
user $User_name $Password
cd $dest_path
put $source_path/*$s*
quit
end_script
done
exit 0
when i am trying to run this is not going for SFTP and also i need to pass password as parameter
can some one help in correcting me need to delver it in a day
Thanks
Deepu
RudiC
April 20, 2015, 11:36am
2
WHAT exactly is not working? Please be very specific, e.g. contents of variables, directories, line no. that works vs line no that doesn't, error messages.
By sheer looking at it, I can't find anything obvious.
sftp cannot take password as a parameter. It -- and nearly all other login methods such as ssh, scp, su and sudo -- are specifically designed to prevent you from doing this because it's an extremely bad idea.
You will need to set up keys .
1 Like
Thanks
for the reply....
can u please send me the scp how to use and how to pass password as a peremeter for scp
i tried this
scp -2v $SOURCE_PATH/*$s* $USER_NAME@$HOST_NAME@$PASSWORD:$dest_path
but it is not working
---------- Post updated at 01:00 PM ---------- Previous update was at 12:08 PM ----------
rudic:
WHAT exactly is not working? Please be very specific, e.g. contents of variables, directories, line no. that works vs line no that doesn't, error messages.
By sheer looking at it, I can't find anything obvious.
SFTP is not functioning in the above script and it is not taking the perameters give and how to pass password as verable
if not please correct the scp part what i have used to pass perameter as verable
You don't.
It's designed so you can't.
Even if it could, it'd be an extremely bad idea. It's preventing you from doing this as a security feature. Plaintext passwords are almost impossible to keep safe!
You need to investigate keys, as I suggested earlier.