LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-07-2012, 10:35 AM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Fetch one file from rsync server - output to stdout


I need to fetch one file from an rsync server. This file is too large to store on disk space due to the system running has booted from a small USB memory stick. The file is actually a CPIO file being used to populate the hard drive of the target system, so that hard drive is also not available for staging the file.

Currently, I am using an HTTP server to do this. But there are multiple issues with that. If this one problem with rsync could be resolved, then that could clear up the other issues short and sweet.

I tried to get rsync to write to /dev/stdout, but it would not do so. I searched for an option for rsync to just write directly to stdout, but found none.
 
Old 06-08-2012, 02:53 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
why rsync? Can you not just cat it over ssh or something like that? rsync is generally run over SSH by any security minded sysadmin these days anyway.
 
Old 06-12-2012, 01:58 PM   #3
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by acid_kewpie View Post
why rsync? Can you not just cat it over ssh or something like that? rsync is generally run over SSH by any security minded sysadmin these days anyway.
RSYNC is actually an easier server to set up than FTP or HTTP. If it had a means to select one file by name, and deliver it to stdout, then I can use it in a script. That script will run on other machines in the network to get one file by name (the name varies and the script even constructs the name from pieces of data). I can do this now with tools like "lynx" or "wget". But I have to set up FTP or HTTP servers to support those, and that's a more complex task to do so and keep secure (mostly because of legacy demands on them to do so many other complex things). RSYNC is easier in part because I've already scripted an on-the-fly rsync server (can be launched from cron with no config setup). I already use that for many other purposes. But in this case I ran into the issue of this involving large files AND no space to stage the file (hence the need to write it to stdout).

For security reasons, every machine on this LAN is unable to ssh directly into any other machine on the LAN. I have tools for doing data transfers manually between machines, which are secure even over the internet. I ssh from "home base" into source and destination machine, and run a script on each. On the source machine the files to send are named. On the destination machine no files are named. The script figures out the data direction that way. On the machine that does listening (can be either source or destination), no address/hostname is given. On the machine that initiates connection, the other machine's address/hostname is given. I give the port number to both, as well as the encryption passphrase ("none" leaves out the encryption overhead, which boosts speed on gigabit secure LANs). It's a nifty script, but it doesn't serve this one case.

I've tried stuff with rsync like using --inplace and --append in conjunction with /dev/stdout, but that doesn't work (and luckily I tried it non-root, or maybe it would have replaced /dev/stdout with a file). It just won't open the existing target for writing. I just can't find anything in rsync to do that.

So at this point I guess I have to invent my own thing or use HTTP (FTP is harder to set up so I won't even bother with that). I don't want the issues that TFTP would have.
 
Old 06-13-2012, 11:58 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
That still doesn't answer acid_kewpie (I think?)
Quote:
Can you not just cat it over ssh or something like that?
In fact, what about http://linux.die.net/man/1/nc or http://linux.die.net/man/1/ncat?
In fact the latter has an option to fake an http proxy if you want, but they both can send to stdout...
 
Old 06-14-2012, 01:33 AM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by chrism01 View Post
That still doesn't answer acid_kewpie (I think?)

In fact, what about http://linux.die.net/man/1/nc or http://linux.die.net/man/1/ncat?
In fact the latter has an option to fake an http proxy if you want, but they both can send to stdout...
The host accessing the data is outside the "trust enough to login via ssh" realm. Basically, ssh isn't an available option.

As for using something like nc, I already have played around with socat (the man page for it on linux.die.net is messed up and needs to be regenerated). But nonw of these offer a safe way to let a name selection be used without adding code to make sure tricks are not used to access things not allowed.

File servers like rsyncd can be made secure. It's just the client can't deliver the file in a way I need in this case (though I use rsync for a lot of other things where files are written to disk and that works well).

If programs like links, lynx, nc, ncat, wget, and such, were to implement rsync as a protocol (some implement http and ftp), then we might have a winner, since these do normally do output to stdout for many things. One possibility is to set up an HTTP server and use "lynx -source http://the.server/name". But I'm trying to avoid the headaches of having a running HTTP server for this. An rsyncd server is much less difficult.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help to have a rsync script log output to a file with time stamp Thaidog Programming 5 11-15-2011 05:37 PM
Help with Rsync and DU commands output to file and mail ssa2204 Linux - Newbie 1 04-29-2011 08:09 AM
Simplest way to output nth line of file to stdout? lumix Linux - Newbie 2 05-18-2008 09:41 PM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
how to output stdout to a file SciYro Linux - Newbie 4 02-25-2004 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration