Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Bash Ftp Automated Image Upload

I am trying to upload an image to ftp server. I am able to upload but uploaded image does not seems as i send. It turns a random colored image on the server side. What is the reason? I changed ftp mode to binary.

#!/bin/sh 
HOST='192.168.10.31' 
USER='ozen.ozkaya'
PASSWD='Oo123456' 
FILE1='RefImg_192.168.10.33_1.jpg'
ftp -n -v $HOST <<END_OF_SESSION 
user $USER $PASSWD 
put $FILE1
bye 
END_OF_SESSION

How can I upload images without corruption?

Regards

like image 317
user1336117 Avatar asked Aug 17 '26 06:08

user1336117


2 Answers

FTP sends in ASCII (7-bit) mode by default; you need to send in binary mode. Add the type binary command before the put, and you'll be all set.

like image 73
Ernest Friedman-Hill Avatar answered Aug 18 '26 19:08

Ernest Friedman-Hill


I am afraid the FTP protocol doesn't support reliable transfers and failover. You will need to script it.

Looking at Ernest response, you did forget to switch the mode to Binary. But if you have a connection failure in the middle of the transfer, don't expect FTP to reinitiate it.

So to answer your question: "How can I upload images without corruption?" Nobody so far provided a valid answer.

I would also recommend WPUT http://wput.sourceforge.net/

A little G search, and here is a project to try: http://lftp.yar.ru/

like image 33
Olivier Refalo Avatar answered Aug 18 '26 19:08

Olivier Refalo