1
Good morning. I have some doubts regarding a project I’m finishing using linux ( I don’t have much domain ).
I have a program written in C that generates files. txt, I must make this program run every day ( until then, I know I must use crontab ). After this file is generated I must send it to a server via FTP. At this point do not know how to proceed, given that I must access the directory that the file was generated, open connection with FTP and upload it.
Another question I’m having is, what is the advantage of using an upload to a server through the FTP protocol?
Edit 1:
I performed the script and until then it works when I step in the file variable the file-source and source-file, however it is necessary to declare a new name, and I would just like to duplicate the files from one place to another.
Follows script:
#!/bin/bash
HOST='192.168.8.151'
usuario='ftp_tentativas'
senha='passwdwillian01'
arquivo='/var/www/html/log/Export/*.csv'
ftp -n $HOST <<END_SCRIPT
user ${usuario} ${senha}
cd recebe
put $arquivo
cp /var/www/html/log/Export/*.* /var/www/html/log/Enviados/.
rm /var/www/html/log/Export/*.*
quit
END_SCRIPT
exit 0
Error showing:
?Invalid command
Could not create file.
Remove directory operation failed.
When done 'by hand' directly by the console it shows the destination equal to the source, not creating the file correctly.
ftp> put /var/www/html/log/Export/*.csv
local: /var/www/html/log/Export/Relatorio_Qualidade_20180730.csv remote: /var/www/html/log/Export/Relatorio_Qualidade_20180730.csv
227 Entering Passive Mode (192,168,8,111,109,45).
553 Could not create file.
I think you are making expensive mess William, the server is server, the server is "not FTP", FTP is a tool installed on the server (and with port released) to facilitate sharing the data between your local machine and another machine, as well as SSH, or even googledrive, but works on a protocol itself (FTP protocol), your server might not have the FTP tool that would still work equally, but you would have to use other methods to upload the files.
– Guilherme Nascimento
@Guilhermenascimento, thanks for the return, but I think I did not know how to express myself, the idea was to explain that I want to send the arch to the server by FTP protocol as you said yourself. But I appreciate the feedback and the specification. opened up a little more my mind haha
– Willian Lima