How to sftp cuurent date file.?

Hi

I am trying to sftp current date file from remote machine but it is no working.

below is the command I am using

sftp root@10.301.31.17 <<EOF
get /home/mohan/scripts/logs/files/*{date +%m%d)*.gz
EOF

What and in which way is not working? If you want meaningful help, way more info about the setup and environment is needed.
You know that there are syntactical and logical errors in your command?

More information than "not working" would be helpful, but I think I see some problems immediately:

  • You should use mget if you want wildcards in filenames. This can find and retrieve one or more matching files.
  • You should use $( ) braces to run external commands and substitute their value in a here document.
  • You should supply the -b flag if you're running sftp in batch mode.
sftp -b root@10.301.31.17 <<EOF
mget /home/mohan/scripts/logs/files/*$(date +%m%d)*.gz
EOF

Plus: the date command is executed on the local node. While the respective internal time may be identical, neither the time zone nor the locale settings have to be.