|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I use the following code to extract an archive and a gzip from an auto-extractible shell script. #! /bin/sh #-- extract binaries from $0 byte_val=`expr $FILEBYTE + 1` tail +${byte_val}c ${CURRENTPWD}/${progname} >binaries.out 2>$NUL [ $? -eq 0 -a -f binaries.out ] || { NO; EXIT $BINARIES_EXTRACTION_FAILED; } #-- extract archive for binaries.out byte_val=`expr $GZIPBYTE + 1` tail +${byte_val}c binaries.out >$tgzarchive 2>$NUL [ $? -eq 0 -a -f "$tgzarchive" ] || { NO; EXIT $BINARIES_EXTRACTION_FAILED; } #-- extract gzip for binaries.out head -c +$GZIPBYTE binaries.out >gzip 2>$NUL [ $? -eq 0 -a -f gzip ] || { NO; EXIT $BINARIES_EXTRACTION_FAILED; } The problem is that the script need to be portable on Linux and most of Unix flavor (HP-UX, AIX, SCO, Solaris, UnixWare) and "head -c" is not supported everywhere (not on SCO, UnixWare, Solaris). Is it possible to reproduce the head -c behaviour with dd command (or with another unix commands ?) TIA and regards, Geoffrey Kretz |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
igeeo76@gmail.com wrote:
> Hi, > > I use the following code to extract an archive and a gzip from an > auto-extractible shell script. > > #! /bin/sh > > #-- extract binaries from $0 > byte_val=`expr $FILEBYTE + 1` > tail +${byte_val}c ${CURRENTPWD}/${progname} >binaries.out 2>$NUL > [ $? -eq 0 -a -f binaries.out ] || { NO; EXIT > $BINARIES_EXTRACTION_FAILED; } > > #-- extract archive for binaries.out > byte_val=`expr $GZIPBYTE + 1` > tail +${byte_val}c binaries.out >$tgzarchive 2>$NUL > [ $? -eq 0 -a -f "$tgzarchive" ] || { NO; EXIT > $BINARIES_EXTRACTION_FAILED; } > > #-- extract gzip for binaries.out > head -c +$GZIPBYTE binaries.out >gzip 2>$NUL > [ $? -eq 0 -a -f gzip ] || { NO; EXIT $BINARIES_EXTRACTION_FAILED; } > > The problem is that the script need to be portable on Linux and most of > Unix flavor (HP-UX, AIX, SCO, Solaris, UnixWare) and "head -c" is not > supported everywhere (not on SCO, UnixWare, Solaris). > > Is it possible to reproduce the head -c behaviour with dd command (or > with another unix commands ?) Yes. Have you read tha man page of dd? (see "bs=..." and "count=..."). Janis > > TIA and regards, > > Geoffrey Kretz > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 5 Dec 2006 07:45:37 -0800, igeeo76@gmail.com
<igeeo76@gmail.com> wrote: > Hi, > > I use the following code to extract an archive and a gzip from an > auto-extractible shell script. > > #! /bin/sh > > #-- extract binaries from $0 > byte_val=`expr $FILEBYTE + 1` > tail +${byte_val}c ${CURRENTPWD}/${progname} >binaries.out 2>$NUL > [ $? -eq 0 -a -f binaries.out ] || { NO; EXIT > $BINARIES_EXTRACTION_FAILED; } > > #-- extract archive for binaries.out > byte_val=`expr $GZIPBYTE + 1` > tail +${byte_val}c binaries.out >$tgzarchive 2>$NUL > [ $? -eq 0 -a -f "$tgzarchive" ] || { NO; EXIT > $BINARIES_EXTRACTION_FAILED; } > > #-- extract gzip for binaries.out > head -c +$GZIPBYTE binaries.out >gzip 2>$NUL > [ $? -eq 0 -a -f gzip ] || { NO; EXIT $BINARIES_EXTRACTION_FAILED; } > > The problem is that the script need to be portable on Linux and most of > Unix flavor (HP-UX, AIX, SCO, Solaris, UnixWare) and "head -c" is not > supported everywhere (not on SCO, UnixWare, Solaris). > > Is it possible to reproduce the head -c behaviour with dd command (or > with another unix commands ?) > dd bs=$GZIPBYTE count=1 if=binaries.out of=gzip For very large files you might need to make bs <= system RAM and count=$((GZIPBYTE / bs)) -- When a girl marries she exchanges the attentions of many men for the inattentions of one. -- Helen Rowland |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
> dd bs=$GZIPBYTE count=1 if=binaries.out of=gzip
> For very large files you might need to make bs <= system RAM and > count=$((GZIPBYTE / bs)) > > > -- > When a girl marries she exchanges the attentions of many men for the > inattentions of one. > -- Helen Rowland Ok, thanks a lot. And as it doesn't use -skip, I guess that this command is portable ? |
|
![]() |
| Outils de la discussion | |
|
|