Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to login to an ftp server using shell scripting in linux?

I want to login to my FTP server using shell scripting. I made a .sh file having contents as

ftp open 172.31.1.45

but it's not working. The second command is not executing. Please help. I am new to linux so please forgive if this is a stupid question

like image 989
Vishnu Ks Avatar asked Dec 01 '25 05:12

Vishnu Ks


1 Answers

try this:

#!/bin/sh
HOST="yourhost"
USER="user"
PASSWD="pass"
FILE="file.txt"
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
like image 187
vahid abdi Avatar answered Dec 03 '25 23:12

vahid abdi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!