Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tar extract to stdout for self-extracting bin

Status
Not open for further replies.

jbeaudry

Programmer
Jun 11, 2006
3
US
Can 'tar' on AIX extract to stdout? On Linux, one can 'tar -x0'. I can't seem to find the equivalent with the version that comes with AIX v5.3.

I'm putting together a self-extracting archive for my app. I'd like to automatically display a license/copyright file that is included in my archive. On Linux, I can do:

tail +$SKIP $0 | gzip -dc | tar -xO License.txt | more

and ask the user to agree before extracting the whole archive. What would be a good way to do that in AIX?

Thanks,
JP
 
Thanks for the suggestion. At this point though, I am quite satisfied with a tarball for packaging. I was just trying to get tar to extract a file to stdout so I can post our license agreement.
 
Thanks for the suggestion. "Makeself" is definitely a very interesting app and oh so close to what I'm looking for. I'm keeping a reference because it's sure to come in handy in the future.

Meanwhile, I've figured some of it out. As far as I can tell, there's no way to untar directly to stdout, but there is a way to untar a stream from stdin. Just replace the '-f filename' with '-f -'. I have resolved to manage my own temporary files.

Also, for whatever reason:
Code:
tail +$numLine myarchive.bin | gzip -dc
doesn't work on AIX. The output of 'cat' can be piped to 'gzip', but then you can't skip some lines.

My solution involves using 'dd' instead to output the tarball part of my archive.
e.g.
Code:
dd -if=myarchive.bin -ibs=$scriptHeaderSizeInChar -skip=1 -obs=1024 | gzip -dc | tar xvf -

I retrieve the size of the header with:
Code:
$headerLines=`awk '/^End_Of_Header_Script/ { print NR;}' myarchive.bin`
$scriptHeaderSizeInChar=`head -$headerLines myarchive.bin | wc -c | sed 's/ *//'`

You could use 'tr' instead of 'sed'.

Good times...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top