I need help with one of my shell script. The script is working fine but i need to add two condition -
i need to get rid of all the below ftp messages and need to have only ftp completed or failed message.
example when i run the script i get below lines -
Connected to xxxx
220 (vsFTPd 2.2.2)
331 Please specify the password.
230 Login successful.
250 Directory successfully changed.
257 "/path/to/1111111"
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
local: x.csv remote: x.csv
i have to check if mypath is present in ftp location. i tried using below if condition but was not succeeded.
ftp -inv $HOST <<-EOF
user $USER $PASSWORD
cd "$mypath"
if [[ $pwd = $mypath ]]
then
mput x.csv
echo "FTP completed"
fi
Below is my shell script -
!/bin/bash
echo "Enter if the env is dev or test or prod:"
while :
do
read -r INPUT_STRING
case $INPUT_STRING in
test | TEST)
echo "Please enter the Model Group no : "
read -r input_variable
if [[ ${#input_variable} -ne "7" ]]
then
echo "Please check no given"
exit 1
fi
HOST=xxx
USER=xxx
PASSWORD=xxx
mypath="/path/to/$input_variable"
ftp -inv $HOST <<- EOF
user $USER $PASSWORD
cd "$mypath"
pwd
mput x.csv
EOF
exit 1
;;
esac
done