Hi All,
I have FTP script snippet
targetFTP=testcomp
userID=testid
userPass=XXXXX
server_availability ()
{
echo "***********************************************************" >> $FtpLog
echo "* Server Availability & User Access Checks *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
ftp -vn $targetFTP <<EOF
user $userID $userPass
pass
bye
EOF
echo "***********************************************************" >> $FtpLog
}
transfer_file ()
{
echo "***********************************************************" >> $FtpLog
echo "* File Extraction *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
ftp -vn $targetFTP <<EOF
user $userID $userPass
pass
bi
lcd $inputDir
cd $outputDir
pwd
mput fiedel-$TDATE*.csv
bye
EOF
echo "***********************************************************" >> $FtpLog
}
Now requirement is to transfer via SFTP due to security restriction.
-
What I did I have generated Public key ssh-keygen and hosted that key to the target machine for password less authentication
-
replace FTP as SFTP as below and run but still it is interactive.
-
how i can make it non interactive so it will not ask password.
targetFTP=testcomp
userID=testid
server_availability ()
{
echo "***********************************************************" >> $FtpLog
echo "* Server Availability & User Access Checks *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
sftp userID$targetFTP<<EOF
pass
bye
EOF
echo "***********************************************************" >> $FtpLog
}
transfer_file ()
{
echo "***********************************************************" >> $FtpLog
echo "* File Extraction *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
sftp userID@$targetFTP<<EOF
pass
bi
lcd $inputDir
cd $outputDir
pwd
mput fiedel-$TDATE*.csv
bye
EOF
echo "***********************************************************" >> $FtpLog
}
scriptoutpt
$./test.sh
Thiscomputer system is FOR OFFICIAL USE ONLY.
sysftp@testcomp's password: