LinuxQuestions.org
Visit Jeremy's Blog.
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-06-2006, 03:31 PM   #1
linux_10_1
LQ Newbie
 
Registered: Jan 2006
Posts: 11

Rep: Reputation: 0
Question Using TAR


Hi,

Is there a function that i can use to tar a particular directory? I need the function that i can use in my code and not from command line. Any response will be very highly appreciated since i am kinda stuck and nearing deadlines

Thanks a lot
 
Old 04-06-2006, 03:37 PM   #2
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Sounds to me like you want us to do your homework without you even trying. Easy homework, too.

Of course you can 'tar' a directory ... $ man tar
 
Old 04-06-2006, 03:53 PM   #3
linux_10_1
LQ Newbie
 
Registered: Jan 2006
Posts: 11

Original Poster
Rep: Reputation: 0
Well, i know that about "man tar" from the command line. It would have been nicer if you read the whole question rather than implying that i am lazy. Well anyway, keeping it professional, what i meant was since i am new to unix, i wanted to ask for a way to INVOKE the tar function from the code, like using some system calls.
 
Old 04-06-2006, 04:07 PM   #4
bosewicht
Senior Member
 
Registered: Aug 2003
Location: Honolulu, HI
Distribution: Arch
Posts: 1,380

Rep: Reputation: 47
He/She was being professional. I agree read over the man pages. Google is also your friend. I mean come on now. Have you tried looking for this answer?
 
Old 04-06-2006, 08:15 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Put it this way, most languages provide the system() cmd or similar.
Which lang are you using?
The system() cmd is like the manual cmd line; same cmds & options are avail ...
 
Old 04-06-2006, 09:30 PM   #6
kirtimaan_bkn
Member
 
Registered: Aug 2004
Location: INDIA
Distribution: Various Distros
Posts: 203

Rep: Reputation: 31
In perl, we can call any command using backquote.
for example :
`tar -zvxf hello.tar.gz`

I am not sure but in "sed", you can also call any command like above. As chris said, there are many languages supporting system() function. You need to just discover what is similar function in the language you are using
 
Old 04-06-2006, 09:37 PM   #7
sumguy231
Member
 
Registered: Apr 2004
Location: North America
Distribution: Kubuntu 7.04 - Feisty Fawn
Posts: 296

Rep: Reputation: 30
The backquotes are usually for capturing output of a command, in normal circumstances I read that system or exec are to be used.
Disclaimer: I am not in any way a perl expert.
 
Old 04-07-2006, 01:08 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Actually, backquotes make the cmd run, same as $(cmd) in shell, similar effect to system() in non-shell langs.
Assigning the results captures the output ...
exec is usually used with fork to create more copies of 'parent' process, although there are variations that overlay/replace parent process with new 'child' process.
An alternative to this is threads, if lang supports it eg C, Perl.
 
  


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 14 10-25-2016 03:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 11:55 AM
.rpms, .tar.gz, .tgz, .src.rpm, & .tar.bz2 whoots Mandriva 10 10-18-2003 01:08 PM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 02:04 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 07:30 AM


All times are GMT -5. The time now is 09:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration