Checksum and pipe an input simultaneously?

If you start off your receiving script with cat > inputfile that will eat all STDIN until EOF, then your script can run any actions needed on inputfile.

Up vote 3 down vote favorite share g+ share fb share tw.

I want to securely move a big file from one computer to another, where it have to be processed before being stored. I thought to pipe file into ssh running the processing script. Local.example.

Com$ cat file | ssh remote.example.com process. Sh (If you have any idea better than mine, please suggest) In the process script I want to both checksum and encrypt the file before saving it. And here comes the problem.

Solutions may be two: pipe input into two commands (cksum and openssl); but all ways I found looked complicated and sub-optional. Hack cksum to also do a cat-like work and print result on stderr, so that I can do cksum --pipe | openssl enc > myfile and get the checksum back via stderr. Unfortunately, I looked into the code and it seems hard for me to do that without doing some performance/buffering damage ;) There may be a cksumming-transfering tool that does this all, but it didn't come me to mind.

Anyway I want to avoid non-standard and complex stuff. Thanks a lot. Edit: useful link about answer linuxjournal.com/content/shell-process-r... bash unix pipe checksum link|improve this question edited May 11 '11 at 16:49 asked May 11 '11 at 15:38FiloSottile456 75% accept rate.

If you start off your receiving script with cat > inputfile, that will eat all STDIN until EOF, then your script can run any actions needed on inputfile. You can also use tee; echo foo | tee >(sha1sum) >(md5sum) d3b07384d113edec49eaa6238ad5ff00 - f1d2d2f924e986ac86fdf7b36c94bcdf32beec15.

– FiloSottile May 11 '11 at 15:55 You could also use tee with process redirection. I'll edit and add an example. – Daenyth May 11 '11 at 15:57 That's it!

I looked at tee but I didn't know about process redirection. Do you think there will be performance drops in process redirection or ssh piping? – FiloSottile May 11 '11 at 16:09 1 @FileSottile, if this answers your question then you should accept it to give Daenyth proper credit.

– glenn jackman May 11 '11 at 16:15 1 @FiloSottile: There is some (very) minor overhead in forking processes -- we're talking milliseconds. Unless this is inside a tight inner loop and repeats often, you will be fine. Make it work first, then profile the code if it's slow.

– Daenyth May 11 '11 at 16:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions