View previous topic :: View next topic |
Author |
Message |
Tribue n00b
Joined: 05 Apr 2007 Posts: 13
|
Posted: Fri Jul 06, 2007 2:07 pm Post subject: [SOLVED ]How to send a file via ftp read from stdin? |
|
|
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 |
|
|
Fabiolla Apprentice
Joined: 04 Mar 2004 Posts: 277 Location: somewhere
|
|
Back to top |
|
|
tobr Guru
Joined: 29 May 2006 Posts: 330
|
Posted: Sun Jul 08, 2007 4:13 pm Post subject: Re: How to send a file via ftp read from stdin? |
|
|
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 |
|
|
Tribue n00b
Joined: 05 Apr 2007 Posts: 13
|
Posted: Sun Jul 08, 2007 8:05 pm Post subject: Re: How to send a file via ftp read from stdin? |
|
|
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 |
|
|
tobr Guru
Joined: 29 May 2006 Posts: 330
|
Posted: Mon Jul 09, 2007 4:07 pm Post subject: |
|
|
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 |
|
|
Tribue n00b
Joined: 05 Apr 2007 Posts: 13
|
Posted: Mon Jul 09, 2007 7:11 pm Post subject: |
|
|
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 |
|
|
|