Spencer
Spencer

Reputation: 22370

How do you connect to FTP server via a shell-script

I am writing my first shell-script ever and I am trying to connect to an FTP server. However, I am utterly at a loss for how to do this. I tried a google search, but I am still stumped.

I am trying to connect with a username and password (not a ssh id).

Thanks for your help. Again this is my first shell-script ever.

Upvotes: 3

Views: 19417

Answers (2)

Samir
Samir

Reputation: 111

Here how you connect to FTP server via a shell-script :

nano MyConnectFTPScript.sh

#!/bin/sh
$HOST='hostAdresss'
$USER='NameOfUser'
$PASSWD='YourPass'
$FILEtoPut='myFile1'
$FILEtoGet='myFile2'
$FILEtoDelete='myFile3'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD

put $FILEtoPut
get $FILEtoGet
delete $FILEtoDelete

quit
END_SCRIPT
exit 0

chmod +x MyConnectFTPScript.sh

and execute : ./MyConnectFTPScript.sh

I hope these will be helpful. Samir

Upvotes: 7

touffy
touffy

Reputation: 147

The command man ftp should give you the necessary pointers. This being said, this page might help you build a complete shell script

Upvotes: 8

Related Questions