tberry
Posts: 5
Joined: Mon Sep 08, 2014 7:11 pm

Vexing wput problem

Mon Sep 22, 2014 10:46 pm

I'm using wput with motion software to transfer a snapshot that motion puts in a folder on the Pi to a server online. Trouble is wput only transfers part of the file and fails every time. If I manually use just FTP it works fine.

The script is called simple.sh and has the following in it:

Code: Select all

#!/bin/bash
echo "Attempting wput..."
wput -B -u --dont-continue --reupload --tries=5 --binary --verbose --reupload ftp://username:password@myservername /home/pi/Desktop/webcam/webcam.jpg
The script is called periodically and appears to work as below but the file only transfers some percent -usually in the mid 90% range, then reports it was successful.

Code: Select all

pi@raspberrypi ~/Desktop/webcam $ ./simple.sh
Attempting wput...
--22:20:42-- `/home/pi/Desktop/webcam/webcam.jpg'
    => ftp://xxxxxx:xxxxx@yyy.yyy.yyy.yy:yy //home/pi/Desktop/webcam/webcam.jpg
Connecting to yyy.yyy.yyy.yy:yy... connected# --------- Welcome to Pure-FTPd [privsep] [TLS] ----------
# You are user number 6 of 500 allowed.
# Local time is now 15:20. Server port: 21.
# This is a private system - No anonymous login
! 
Logging in as xxxxxxxx ... Logged in!
==> CWD home/pi/Desktop/webcam
Remote file size is smaller than local size. Restarting at 0.
==> TYPE I ... done.
==> PASV ... done.
==> STOR webcam.jpg ... done.
Length: 81,354
96% [==============================================================================================>  ] 78,848           33.00K/s ETA    00s
# File successfully transferred
22:20:45 (webcam.jpg) - `33.01K/s' [81354]

# Goodbye. You uploaded 80 and downloaded 0 kbytes.
FINISHED --22:20:45--
Transfered 81,354 bytes in 1 file at 23.56K/s
I'm having a real hard time debugging this. I've also tried the wput line in the motion.conf file but it doesn't seem to activate. Probably it is getting the same result as above. I've searched this forum and the web for reports of a problem like this but found nothing.

Any help is appreciated.

User avatar
DougieLawson
Posts: 39126
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Vexing wput problem

Mon Sep 22, 2014 11:19 pm

Why bother with FTP? It's insecure and unreliable.

Your Raspberry Pi is running sshd (because that's what lets you use PuTTY with an ssh session to port 22), so you can use scp or sftp. With a private key on the origin and a public key in ~/.ssh/authorized_keys on the target system you can use scp or sftp without needing a password.

For a single file scp is easy

Code: Select all

scp /home/pi/filetosendfromthelocalsystem user@example.com:/home/user/filetostoreontheremotesystem
You can run it the other way round to retrieve a file

Code: Select all

scp user@example.com:/home/user/filetosend /home/pi/filenametostoreonthelocalsystem
if the userid at the local system and remote system are identical you can use

Code: Select all

scp ~/filetosend example.com:~/filetostore
The only requirement is that the file you're sending is flushed and closed on the sending system.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Vexing wput problem

Tue Sep 23, 2014 7:10 am

It looks like the number of bytes transferred is correct. Did the file actually upload ok? Have you tried copying it back again to another file using wget, then comparing them?

I note that you have some options duplicated on your wput command line. I don't know if this will confuse the software (it shouldn't but...). You have both -B and --binary. They are the same option. You also have --reupload twice.
DougieLawson wrote:Why bother with FTP?
Some servers only have the option of FTP for file upload. One that I have to use doesn't have the option of SSH (yet). Note that tberry said they are uploading from their Pi to a remote server.

tberry
Posts: 5
Joined: Mon Sep 08, 2014 7:11 pm

Re: Vexing wput problem

Tue Sep 23, 2014 2:54 pm

Okay, a serious Linux noob mistake here. The wput and ftp is in fact working. I'd misunderstood the command and it was placing the image on the SERVER in /home/pi/Desktop/webcam/webcam.jpg

I thought that was where I wanted it to get the file FROM (the RPI).

The FTP username only has access to a single folder on the server and that is where the wput command created a set of nested folders (/home/pi/Desktop/webcam/webcam.jpg).

I've corrected the error now and it is in fact uploading properly. Sorry for the mistake and thanks for the help.

Return to “Troubleshooting”