Skip to content
Advertisement

Handling Dates in FTP

Here is my ftp script

#!/bin/sh
FTPHOST='dedibackup-dc2.xx.net'
FTPUSER='sd-xxxxx'
FTPPASSWD='xxxxxxxxxxxxxx'

ftp -n -v $FTPHOST << EOT
ascii
user $FTPUSER $FTPPASSWD
prompt

now=$(date +"%d-%m-%Y")
echo $now
bye
EOT

The output of this script is:

Trying 62.210.XX.XX...
Connected to dedibackup-dc2.XXXX.net (62.210.XX.XX).
220 server ready - login please
530 login first
331 password required
230 login accepted
Interactive mode off.
?Invalid command
?Invalid command
221 goodbye

I googled and seen some posts regarding dates but all provided formats not worked for me.

Please advise

Thanks in anticipation

Advertisement

Answer

through to FTP, which can include executing commands, substituting variables, and the like. That is to say, instead of writing:

ftp < ftp_args> << EOT
blah
bloho $VAR1
bleeeoogah $(some cmd)
EOT

just do this:

( echo blah; echo bloho $VAR1; echo bleeeoogah $(some_cmd) ) | ftp

Advertisement