[comp.sys.amiga] unix sh dearchiver

kzyx@vax5.cit.cornell.edu (11/05/90)

       Is there a version of UNIX shar for the amiga SHELL?

       It seems to me that it should not be all that difficult to implement
it, and it would reduce the amount of work to get some ftp'ed files up and
running in my amiga.
       Now I use a sparcstation to de-archive.
       Any clues...

               *****************************************
               *********         *                     *
                *                *         **********  *
                 *               *        *   ****     *
                  *        ****  * *     *        *    *
                 *        *      *  *   *    ******    *
                *         *      *   * *    *     *    *
               *********   ****  *    *      *******   *
               *****************************************
       Edval Santos
               esantos@macdlab.ee.cornell.edu
               kzyx@vax5.cit.cornell.edu

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (11/05/90)

In <1990Nov4.153626.808@vax5.cit.cornell.edu>, kzyx@vax5.cit.cornell.edu writes:
>       Is there a version of UNIX shar for the amiga SHELL?

Not that I know of. I think the main problem is that there is no '<<' operator
to enable input from the shar file itself.

It would be reasonably easy to write something in Arexx, however.

-larry

--
It is not possible to both understand and appreciate Intel CPUs.
    -D.Wolfskill
+-----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                 |
| \X/    lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips |
|        COMPUSERVE: 76703,4322  -or-  76703.4322@compuserve.com        |
+-----------------------------------------------------------------------+

tadguy@abcfd01.larc.nasa.gov (Tad Guy) (11/06/90)

In article <1990Nov4.153626.808@vax5.cit.cornell.edu> kzyx@vax5.cit.cornell.edu writes:
> It seems to me that it should not be all that difficult to implement
> it, and it would reduce the amount of work to get some ftp'ed files
> up and running in my amiga.

You might want to try unshar, posted to comp.sources.amiga.  It's
archived on abcfd20.larc.nasa.gov as

Sun  20-Jan-90  05:22:28    30185 usenet/comp.sources.amiga/volume90/unix/unshar-1.2.Z

	...tad

joseph@valnet.UUCP (Joseph P. Hillenburg) (11/07/90)

lphillips@lpami.wimsey.bc.ca (Larry Phillips) writes:

> In <1990Nov4.153626.808@vax5.cit.cornell.edu>, kzyx@vax5.cit.cornell.edu writ
> >       Is there a version of UNIX shar for the amiga SHELL?
> 
> Not that I know of. I think the main problem is that there is no '<<' operato
> to enable input from the shar file itself.
> 
> It would be reasonably easy to write something in Arexx, however.
> 
> -larry
> 
> --
> It is not possible to both understand and appreciate Intel CPUs.
>     -D.Wolfskill
> +-----------------------------------------------------------------------+ 
> |   //   Larry Phillips                                                 |
> | \X/    lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips |
> |        COMPUSERVE: 76703,4322  -or-  76703.4322@compuserve.com        |
> +-----------------------------------------------------------------------+

I got a copy of UnShar from a Fish disk somewhere. (Sorry, I'm too lazy 
too look it up :)

-Joseph Hillenburg

UUCP: ...iuvax!valnet!joseph
ARPA: valnet!joseph@iuvax.cs.indiana.edu
INET: joseph@valnet.UUCP

@utrcgw.utc.com:mark@ardnt1 (mark) (11/07/90)

on 4 Nov 90 19:36:26 GMT,kzyx <kzyx@vax5.cit.cornell.EDU> said:

  >        Is there a version of UNIX shar for the amiga SHELL?

  >        Edval Santos
  >                esantos@macdlab.ee.cornell.edu
  >                kzyx@vax5.cit.cornell.edu



on 5 Nov 90 22:09:12 GMT,Tad Guy <tadguy@abcfd01.larc.nasa.GOV> said:

    Tad> In article <1990Nov4.153626.808@vax5.cit.cornell.edu> 
kzyx@vax5.cit.cornell.edu writes:

    Tad> You might want to try unshar, posted to comp.sources.amiga.  It's
    Tad> archived on abcfd20.larc.nasa.gov as

    Tad> Sun  20-Jan-90  05:22:28    30185 usenet/comp.sources.amiga/volume90/unix/unshar-1.2.Z

    Tad> 	...tad



I sent this on to Edval, but I thought someone else might be interested in it.


------------------------------------------------------------------------------
| Mark Stucky                         | Email:                               |
| United Technologies Research Center |   mark%ardnt1@utrcgw.utc.com         |
| East Hartford, CT.                  |   mast%utrc@utrcgw.utc.com           |
------------------------------------------------------------------------------





#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	unsh.doc
#	unsh.c
# This archive created: Wed Nov  7 08:57:40 1990
cat << \SHAR_EOF > unsh.doc




  This silly little program is Copyright 1990 by Kevin Smathers,
all rights reserved.  Permission is granted to distribute this
program through normal freely distributable routes.

  This program (in a single routine) parses shell archives to
extract their contents.  It cheats somewhat by knowing the
format of the file.  File lines are assumed to begin with an
'X' character, (although any could theoretically be used) and
it doesn't really try to parse the parameters to 'sed', it just
looks for an output filename.

  These and other limitations should be easy enough to fix should
it ever become neccessary.  (The program *is* pretty robust.
It should be pretty difficult to crash it even with random input
files.)  Really the only reason this program exists is because
'unbob' stopped working on me about 5 months ago, and 'shar' has
always guru'd when I run it with the '-u' switch.  The obvious
solution was to write a program which wouldn't crash.

  To extract files from a shell archive, invoke UNSH with the
name of the shell archive: E.g:

    UNSH filename

  Running UNSH without any parameters will produce a short usage
note, and the revision number.


                           -Sullivan Segall
_________________________________________________________________

/V\  Sullivan  was the first to learn how to jump  without moving.
 '   Is it not proper that the student should surpass the teacher?
To Quote the immortal Socrates: "I drank what?" -Sullivan
_________________________________________________________________

Mail to: ...sun!portal!cup.portal.com!Sullivan or
         Sullivan@cup.portal.com



SHAR_EOF
cat << \SHAR_EOF > unsh.c
#ifndef _UNSH_
#define _UNSH_ 0,10
/*  unsh.c -- V0,10
.he unsh.c -- V0,10
*
*   This program (in a single routine) parses shell archives to
*   extract their contents.  It cheats somewhat by knowing the
*   format of the file.  File lines are assumed to begin with an
*   'X' character, (although any could theoretically be used) and
*   it doesn't really try to parse the parameters to 'sed', it just
*   looks for an output filename.
*
*   These and other limitations should be easy enough to fix should
*   it ever become neccessary.  (The program *is* pretty robust.
*   It should be pretty difficult to crash it even with random input
*   files.)
*
*   This silly little program is Copyright 1990 by Kevin Smathers,
*   all rights reserved.  Permission is granted to distribute this
*   program through normal freely distributable routes.
*/



#include <ctype.h>
#include <string.h>
#include <stdio.h>

#define TRUE -1
#define FALSE 0


void main(
    int argc,
    char *argv[]
    )
{
#define BUFMAX 250
    char buf[BUFMAX+1];
    char catend[20];
    char *fnam;
    int catmode = FALSE;
    FILE *fp;
    FILE *fo = NULL;
    int i;
    catend[0] = 0;
    if (argc != 2)
    {
        printf("Usage: UNSH <filename>\n");
        printf("Extracts files from a SHAR archive.\n");
        printf("Version %d,%2d\n",_UNSH_);
        return;
    }
    fp = fopen(argv[1],"r");
    if (fp == NULL)
    {
        printf("File not found.\n");
    }
    while (!feof(fp))
    {
        if (fgets(buf,BUFMAX,fp) == NULL)
        {
            if (ferror(fp))
            {
                printf("Error reading source file.\n");
            }
            break;
        }
        if (fo != NULL &&
            strncmp(buf,catend,strlen(catend)) == 0)
        {
            fclose (fo);
            printf("End of file\n");
            fo = NULL;
            catmode = FALSE;
        } else
        if (catmode &&
            fo != NULL)
        {
            fputs(buf,fo);
        } else
        if (strncmp(buf,"echo",4) == 0)
        {
            puts(buf+5);
        } else
        if ((strncmp(buf,"sed",3) == 0) ||
            (strncmp(buf,"cat",3) == 0) && (catmode = TRUE) != 0)
        {
            if (fo != NULL)
            {
                fclose (fo);
                printf("End of file\n");
                fo = NULL;
                catmode = FALSE;
            }
            for (i=0; buf[i] != 0 && buf[i] != '\\'; i++);
            if (buf[i] == '\\')
            {
                i++;
                fnam = &buf[i];
                while (isgraph((int)buf[i])) i++;
                if (i<=BUFMAX) buf[i] = 0;
                if (strlen(fnam) > 0)
                {
                    strncpy(catend,fnam,20);
                    catend[19] = 0;
                }
                i++;
            }
            for (; buf[i] != 0 && buf[i] != '>'; i++);
            if (buf[i] == '>')
            {
                i++;
                while (buf[i] == ' ') i++;
                fnam = &buf[i];
                while (isgraph((int)buf[i])) i++;
                if (i<=BUFMAX) buf[i] = 0;
                if (strlen(fnam) > 0)
                {
                    fo = fopen(fnam,"w");
                    printf("Starting file %s\n",fnam);
                }
            }
        } else
        if (buf[0] == 'X' &&
            fo != NULL)
        {
            fputs(buf+1,fo);
        }

    }
    if (fo != NULL)
    {
        fclose (fo);
        printf("End of file\n");
    }
    fclose(fp);

}
#endif ndef _UNSH_
SHAR_EOF
#	End of shell archive
exit 0