Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (9.5k points)

In order to check for FTP connection in the bash script with simple login data. 

I used wput and grep to get my output. Can anyone tell me how to do it in a simple way?

1 Answer

0 votes
by (19.7k points)

To test the connection with wget, see the code below:

wget --spider --tries=1 --user=login --password=pass ftp://your-ftp.com/

if [ $? -ne 0 ]; then

    echo "Failed to connect to ftp host"

fi

See the below code snippet for FTP connect: 

echo 'exit' | ftp ftp://login:[email protected]/

if [ $? -ne 0 ]; then

    echo "Failed to connect to ftp host"

fi

If you want to learn more about Linuxthen go through this Linux tutorial by Intellipaat for more insights.  

Related questions

0 votes
1 answer
asked Dec 5, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
asked Dec 1, 2020 in Linux by blackindya (18.4k points)

Browse Categories

...