Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED ]How to send a file via ftp read from stdin?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Tribue
n00b
n00b


Joined: 05 Apr 2007
Posts: 13

PostPosted: Fri Jul 06, 2007 2:07 pm    Post subject: [SOLVED ]How to send a file via ftp read from stdin? Reply with quote

I am looking for something like that:

ntfsclone --save-image --output - /dev/hda1 | gzip -c | ssh host ’cat > backup.img.gz’

but to send the file to an ftp server instead of a ssh server. Is this possible? I have searched google but nothing useful found.


Last edited by Tribue on Mon Jul 09, 2007 7:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
Fabiolla
Apprentice
Apprentice


Joined: 04 Mar 2004
Posts: 277
Location: somewhere

PostPosted: Fri Jul 06, 2007 4:58 pm    Post subject: Reply with quote

Hi,
mounting the ftp is one possible solution.
A quick google search about mounting ftp: http://blog.tarotoast.com/2006/04/02/242/
greetings
Back to top
View user's profile Send private message
tobr
Guru
Guru


Joined: 29 May 2006
Posts: 330

PostPosted: Sun Jul 08, 2007 4:13 pm    Post subject: Re: How to send a file via ftp read from stdin? Reply with quote

Tribue wrote:
I am looking for something like that:

ntfsclone --save-image --output - /dev/hda1 | gzip -c | ssh host ’cat > backup.img.gz’

but to send the file to an ftp server instead of a ssh server. Is this possible? I have searched google but nothing useful found.


FIFOs are your friends! (see also man mkfifo). A fifo looks like a file, but works like a pipe. You can do the following in one terminal:
Code:
mkfifo /tmp/my_fifo
ntfsclone --save-image --output - /dev/hda1 | gzip -c > /tmp/my_fifo
then you can open another terminal and do
Code:
ftp ftp.server.com
# Connect authenticate etc.
# Now you're in the ftp client program:
put /tmp/my_fifo backup.img.gz
. You can of course use every ftp client that doesn't complain about the FIFO. Just treat the FIFO like a normal file you'd like to upload.

A bit "theory" if you're interested:

A FIFO (First In First Out) is a named pipe. It works like "|" in the shell but can be accessed like a regular file. So you can grep/cat/ftp/whatever it. As soon as you write something to a fifo the writing process stalls. When you read from the fifo the writing process starts to write and the reading process reads its output.

HTH
_________________
Please add [SOLVED] to your message title if your problem is solved.

Death to all blobs!
Back to top
View user's profile Send private message
Tribue
n00b
n00b


Joined: 05 Apr 2007
Posts: 13

PostPosted: Sun Jul 08, 2007 8:05 pm    Post subject: Re: How to send a file via ftp read from stdin? Reply with quote

tobr wrote:
Tribue wrote:
I am looking for something like that:

ntfsclone --save-image --output - /dev/hda1 | gzip -c | ssh host ’cat > backup.img.gz’

but to send the file to an ftp server instead of a ssh server. Is this possible? I have searched google but nothing useful found.


FIFOs are your friends! (see also man mkfifo). A fifo looks like a file, but works like a pipe. You can do the following in one terminal:
Code:
mkfifo /tmp/my_fifo
ntfsclone --save-image --output - /dev/hda1 | gzip -c > /tmp/my_fifo
then you can open another terminal and do
Code:
ftp ftp.server.com
# Connect authenticate etc.
# Now you're in the ftp client program:
put /tmp/my_fifo backup.img.gz
. You can of course use every ftp client that doesn't complain about the FIFO. Just treat the FIFO like a normal file you'd like to upload.

A bit "theory" if you're interested:

A FIFO (First In First Out) is a named pipe. It works like "|" in the shell but can be accessed like a regular file. So you can grep/cat/ftp/whatever it. As soon as you write something to a fifo the writing process stalls. When you read from the fifo the writing process starts to write and the reading process reads its output.

HTH


The idea is really good, but for some reason the ftp does not accept the file. Says "/tmp/myfifo: not a plain file"
I think it is not possible, as I have read here:
http://www.unix.com/sun-solaris/34657-ftp-transfer.html
http://www.velocityreviews.com/forums/t124023-re-reading-a-file-thats-actively-being-written-to.html

If you have some other idea...
Back to top
View user's profile Send private message
tobr
Guru
Guru


Joined: 29 May 2006
Posts: 330

PostPosted: Mon Jul 09, 2007 4:07 pm    Post subject: Reply with quote

Try with net-ftp/lftp. This works for me. ftp whines about the file, as you said. BTW, lftp has generally more features as auto-completion.
_________________
Please add [SOLVED] to your message title if your problem is solved.

Death to all blobs!
Back to top
View user's profile Send private message
Tribue
n00b
n00b


Joined: 05 Apr 2007
Posts: 13

PostPosted: Mon Jul 09, 2007 7:11 pm    Post subject: Reply with quote

tobr wrote:
Try with net-ftp/lftp. This works for me. ftp whines about the file, as you said. BTW, lftp has generally more features as auto-completion.


Thank you! It worked!
I don´t know why distros do not include this ftp client instead of the default one and simply call it ftp, if works better in all ways, it is just stupid and irritating that they don´t do that.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum