LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-10-2006, 03:18 PM   #1
linux_10_1
LQ Newbie
 
Registered: Jan 2006
Posts: 11

Rep: Reputation: 0
Question how to pipe my tar file


Hi,

Say I am doing a tar of a particular directory by
"tar -cf newtarfile /opt"

then newtarfile is the tar of the directory /opt.

Now instead of putting the "newtarfile" on my unix harddisk, I would like to send it to another machine simultaneously as it is taring. I do have sockets and use write to write to the other machine. My question is how do i use the output of this and use it as an input to my write function. I am using the unix "write"function.

I am invoking the tar from my code using the system command. Now i am trying to somehow redirect the output. Any ideas/help using the pipe is highly appreciated.

Thanks,
 
Old 04-10-2006, 06:51 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 48
you give "-" as the filename and tar will output to standard output; for example, to tar and send it to another machine through SSH, do
Code:
tar cf - /opt | ssh user@host "cat > newtarfile"

Last edited by spooon; 04-10-2006 at 06:53 PM.
 
Old 04-11-2006, 11:28 AM   #3
linux_10_1
LQ Newbie
 
Registered: Jan 2006
Posts: 11

Original Poster
Rep: Reputation: 0
I already have sockets for the communication. Already a function write_sock is there which uses the unix " write (int socket, (void*)ptr, int numberofbytes);"

Now how do i tell the tar function to send it to this socket?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 10 02-23-2008 05:40 AM
tar problems, trying to pipe through split microsoft/linux Linux - Software 13 03-04-2006 08:20 PM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM
tar -cvzf file.xml file.tar.gz RickHunter_Ve Linux - Software 1 10-06-2004 12:58 PM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 01:04 PM


All times are GMT -5. The time now is 07:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration