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 -
Code:
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.
Code:
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 -
Code:
!/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
Moderator's Comments:
Permanently ignoring hints to use code tags, you have accumulated enough infraction points for a read-only ban.
Hi
I am new to this forum.I need a help in the following:
We receve pipe delimited file with
transaction ID,tran_date,Quest_cd,Ans_cd,ans_value.
Same transaction ID can be repeated with different quest_cd and ans_cd.
Basically I need to check if a perticular pair of quest_cd and ans_cd... (1 Reply)
How to validate a date and optionly a time in shell scripting when i get the date and time as pararmeters that sent out with the call of the file? (in my case sh union.sh `first parameter ,second parameter...` (4 Replies)
Hi,
Can anyone provide me the code snippet for EMail Address Validation.
User is going to enter the email address in form window. I need to validate the format is correct.
Thanks in Advance
BS (3 Replies)
Hi All,
I'm trying to run a similar script to copy a files from one location to another.
#!/bin/bash
source="/home/pradeepk/a.txt"
destination="/home/pradeepk/dir1"
cp $source $destinationi'm getting following error.
cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directorywhen... (1 Reply)
Hi All,
I have a shell script in Linux and it will be invoked by 2 methods,
1) An automated background process .
2) Logining into the box and directly executing the script.
I need to put a validation in my shell script such that it will be executed successfully on when an... (11 Replies)
Hi All,
I am a newbie...I would like to have a function which ll check if a file contains valid strings before "=" operator. Just to give you my requirement:
assume my file has content:
hello= gsdgsd sfdsg sgdsg sgdgdg
world= gggg hhhh iiiii
xxxx= pppp ppppp pppp
my... (1 Reply)
Hi everyone,
I have been using a shell script for the last 6 months to copy a database from a POS system, then analyse the database and print the current sales total. This has worked flawlessly, the only issue was that I had hard coded the IP address of the POS and occasionally I would need to... (23 Replies)
hello every one
I wrote the script to validate all the urls from my server . sourcing text file which contains the list of urls and trying to check every url and based on response printing url is up or not. the issue when i use the below code with url is printing url exist and and in loop it's... (3 Replies)