##       #! /command/bash        needs this if run from login IIRC
## cLIeNUX /.bi/guide   19991010     rah
## see what works. Try a bunch of commands.

beep
COLUMNS=90

clear
stc

echo "This is a guide to cLIeNUX Core. For demo, testing, config..."
echo "guide   is a shell script. You can read it, learn from it, customize it."
echo "If further output is messed up change the COLUMNS=90 in /command/guide"
echo 


format -w $COLUMNS << BLA
Usually just keep hitting <enter> Or shift&page-up to 
scroll back. In many
cases you can hit s<enter> to skip a section that sticks you in an
interpreter of some kind. ctrl&c sends an "End Of Transmission" to a
running program or script, which usually kills it. If guide puts you in
the browser one ctrl&c will probably bring you back to the script, or you
can follow the browser's directions to exit it. The text color changes are
courtesy of the stc command. 

If you exit guide before it finishes you'll be left with non-standard 
colors, and maybe an odd or messed up font. 
	textcolor -r 
will fix the colors, and 
	setfont
will give you a usable font. You can also try 
	normal
.

BLA
read JUNK
clear
stc

format -w $COLUMNS << YERP


Hit "s<enter>" if you don't want to try various fonts. 








YERP




read JUNK

if test "$JUNK" != "s" ;
then 
fonts
fi



clear
stc



format -w $COLUMNS << BLA

cLIeNUX guide

There are some parts to this that are a bit overbearing. Sorry about that, but you
really want to learn the basic concepts of a unix shell ASAP, so "guide" is part 
tutorial also. The reason for that is I'm not in the business of keeping you ignorant. 
cLIeNUX doesn't make the distinction between user 
and developer. That's the reason cLIeNUX exists. This is how cLIeNUX matches the nature
of open source software in ways other Linux/GNU/unix distributions don't.
That doesn't mean you have to be a kernel developer to use cLIeNUX, but you do have 
to know basic concepts of the unix shell. Making Linux/GNU/unix familiar to e.g. 
Microsoft Windows  
users is only valid to the extent that doing so doesn't cripple them all over again. 
Pay attention. 



BLA

read JUNK
clear
stc


format -w $COLUMNS <<BLA

cLIeNUX guide

From your command prompt there are commands, files, and shell directives.
There are several features of unix that enhance this simple layout tremendously.
One nice thing is all files are in the same namespace under "/" .
Another is that lots of things that aren't really files can be treated
as files by any command. Examples include entire storage devices,
harddrive partitions, and all the other /dev files, which make device
drivers and kernel services like /dev/zero look like files.
This flexibility is delightful, "but there's more!". Any time unix runs a stand-alone 
program, i.e. a command, it endows that command with 3 file descriptors known as 
stdin, stdout, and stderr.  So.... 

BLA
echo "(hit enter)"
read JUNK

clear
echo "cLIeNUX guide"
echo
format -w $COLUMNS <<BLA

 stdin is standard input to the command, stdout is the standard output
 of the command, and stderr is the standard error output of the command.
 These are 3 general-purpose connectors to any unix command. The default
 is that all three be connected to the terminal the user of the command 
 invokes it from, since terminals also look like files. But here's the
 groovy bit; the shell can redirect input and output of any command. 
BLA

read JUNK

clear
stc
echo "cLIeNUX guide"
echo
format -w $COLUMNS <<BLA
 For example, as the superuser you can write to the floppy drive
 as if it was a single file named /device/fd0. This is
 fundamental to the modularity of unix. MSDos has had stdin, stdout and stderr
since version 2, but it isn't built from the ground up to take advantage of them.
In unix, if a thing like a floppy
 has a filesytem on it, that filesystem can be "mount"ed on the main  
 file tree somewhere, but it's also still /dev/fd0. The generality 
 of this combines with shell redirection. The shell can tell most
 commands where to send thier output. This is done with the
 <   >   <<   >> and   |   shell directives. | sends output of a
 command to another command. This is called a pipe. < > << and >>
 allow the shell to send the output of a command to a file. So, as
 a demo, put any old floppy in the floppy drive, and this script
 will copy the whole thing to /floppyimage   by simply doing
 cp /device/fd0 /floppyimage .
BLA

 

read JUNK
if test "$JUNK" != "s" ;
then {
clear
echo "cLIeNUX guide"
echo
echo "doing the copy..."
cp /dev/fd0 /.tm/floppyimage

echo "now a listing, ls /.tm   ...."
echo
echo
echo
ls --color -s /.tm
echo
echo "Do you see it up there?" 
echo
echo "Now let's see what it looks like with the \"sniff\" command..."
read JUNK
clear

echo "cLIeNUX guide"
echo 

sniff /.tm/floppyimage
echo
echo "and now we remove it..."
rm /.tm/floppyimage
};
fi

read JUNK
clear
stc
echo "cLIeNUX guide"
echo
format -w $COLUMNS << PLA
 Now let's do some redirection.
 partition -l lists known HD partitions, usually on the terminal. Let's
 send that to a file instead, with   partition -l  >  /fdiskl. We'll also
 get it to the screen.
PLA

read JUNK

if test "$JUNK" != "s" ;
then {

partition -l >  /fdiskl
get /fdiskl

};
fi




echo "cLIeNUX guide" 
echo

echo " Now we can list it backwards with \"reverse\"...."
echo
read JUNK
echo
clear
reverse /fdiskl
rm /fdiskl
echo
echo 
format -w $COLUMNS << PLA
 Pretty wacky, eh? It's nice what you can do when you can get 
 ahold of things. We could have done this with | without the 
 file, but sometimes you want a file. 
PLA
stc
read JUNK
clear
echo "cLIeNUX guide" 
echo
format -w $COLUMNS <<HERE
 Remember that I said *all* unix commands have
 standard in, out and error? Not all commands use all 3, but in most
 cases that means you can even "script"
 interactive commands like browse, edit and spreadsheet. If you do 

       interactivecommandlikeedit < file

 then the command thinks the file is user input, as if the user was
 inputting those commands interactively from the terminal, standard input.
 The "scripting language" is the normal user input of the command.
 For example, lets try a goofy browse script...
HERE
textcolor -r

read JUNK


browse  / <<HEREDOC
?
o
q
y
HEREDOC
browse  /command <<HEREDOC
?
o
q
y
HEREDOC
browse  /help/configuration.html <<HEREDOC
?
o
q
y
HEREDOC
browse  /.li <<HEREDOC
?
o
q
y
HEREDOC
stc
clear
format -w $COLUMNS <<EUI
 Nuts? 



 Well, that wasn't a particularly useful example, but
 the point is the utter generality of shell redirection.
 Powerful stuff.
EUI

read JUNK
clear
stc


echo "cLIeNUX guide"
echo
echo
format -w $COLUMNS <<BLA
 cLIeNUX has most of it's help files in the /help directory.
 Lets browse that dir with \"browse\", also known as Lynx...
 ( /help/configuration.html is exactly that, BTW. )
BLA

textcolor -r
read JUNK
if test "$JUNK" != "s" ;
then {

browse /help
};
fi

echo 
echo
clear
stc
echo "cLIeNUX guide"
echo
echo " This next is    ps   or pstree   , which is a display of active processes."

read JUNK

if test "$JUNK" != "s" ;
then {
pstree -p
};
fi

read JUNK
clear
stc

echo 
echo "cLIeNUX guide"
echo 
format -w $COLUMNS <<BLA
 I'm gonna stick you in spreadsheet. Hit q to get out. The template in the example 
 is for calculating video timings for X and SVGATextMode, by the way.
BLA

read JUNK
if test "$JUNK" != "s" ;
then {

spreadsheet /help/modes.wo
};
fi

echo 
echo
echo
clear
stc


echo "cLIeNUX guide"
echo
echo
echo
echo " BTW (\"by the way\"), if spreadsheet worked you have libm, the math library."
echo
echo " Here goes   see mount   which needs see, page, browse and \
/help/see/mount.1.man" 
echo " (q   should escape  see    )"
read JUNK
textcolor -r
if test "$JUNK" != "s" ;
then {

see mount
};
fi



clear
stc
echo 
echo "cLIeNUX guide"
echo
format -w $COLUMNS <<NNNN
 bootmessage prints out the kernel text buffer, which contains the boot
 messages, and may contain other subsequent stuff about kernel modules or filesystems
 being mounted unchecked or actual corruption. 

NNNN

read JUNK
if test "$JUNK" != "s" ;
then {

bootmessage
};
fi
echo
echo "cLIeNUX guide"
echo
echo

echo
echo " Recall that you can scroll your terminal back with shift&page_up."
echo "So, what are your box's bogoMIPS?"


read JUNK
clear
echo
stc

echo "cLIeNUX guide"
echo
format -w $COLUMNS <<BLA
 OK, here's a bit of low-level info that was best saved till after we looked at the 
 kernel ring (text) buffer. There's several info hotkeys that are pretty much always 
 available that give system stats. They send thier output to the console screen 
 regardless of what else is going on on the console at the time. They are 
 shift&scroll_lock, ctrl&scroll_lock and right_alt&scroll_lock. Try em. Hit return and
 guide will continue. 
BLA




read JUNK
clear
echo
stc
echo "cLIeNUX guide"
echo
echo "Your fonts, in /configure/console/fonts, are ......"
if test "$JUNK" != "s" ;
then {
ls /.et/console/fonts
};
fi

read JUNK
clear
stc

echo "cLIeNUX guide"
echo

format -w $COLUMNS <<BLA

 Now lets browse your kernel...

 Your /linux directory is a pseudo-directory of read-only kernel
 information. This is a window into the actual current state of the system.
 This puts all the crucial kernel info into the filesystem
 namespace. IF your kernel is configured for /linux, and it's mounted,
 we will now browse your kernel. The numbers in /linux/ are PIDs,
 process IDs. init is PID 1. Hit q and then y or ctrl&c to escape browse....
BLA

textcolor -r
read JUNK
if test "$JUNK" != "s" ;
then {

browse /.pro
};
fi

stc
echo
echo "cLIeNUX guide"
echo 
format -w $COLUMNS <<BLA

 Each system process has it's own environment variables. 
 set   will show us the ones for this shell......

BLA

read JUNK
if test "$JUNK" != "s" ;
then {
set
};
fi

read JUNK
clear
stc
echo
echo
echo "cLIeNUX guide"

echo
format -w $COLUMNS <<BLA
 cLIeNUX Core doesn't have   locate   and the locate database.
 We can easily generate a simple file-list file for quick look-ups.
 If you don't hit s here we'll make a /help/filelist right now.
 Read /command/guide for examples of this and other commands.
 guide is simple code, mostly, except for the gcc demo. You can 
 see the commands it uses.
BLA

read JUNK
if test "$JUNK" != "s" ;
then {
	find / -xdev > /help/filelist
};
fi


echo "cLIeNUX guide"
echo
echo

format -w $COLUMNS <<BLA
 Now you have a /help/filelist you can scan or grep. Instead of
 just hitting <enter> here, type in a short string of characters
 you'd like to scan for in /help/filelist, or we'll scan for 
 info   if you just hit enter.




BLA

read JUNK
if test "$JUNK" != "s" 
then {
	if test "$JUNK" != ""  
	then {
		scan $JUNK /help/filelist
	     }
	else {
		scan info /help/filelist
             }
	fi
}
fi


echo

read JUNK
clear
stc

echo
echo "cLIeNUX guide"
echo

format -w $COLUMNS <<BLAAL
 netface (ifconfig)     with no parameters will list active network interfaces,
 such as ethernets or PPP.
 127.0.0.1  is the IP address of the local box. Handy for testing.
 e.g.   ping 127.0.0.1


BLAAL

read JUNK
stc
if test "$JUNK" != "s" ;
then {

ifconfig
};
fi
read JUNK
clear
stc
echo
echo
echo "cLIeNUX guide"
echo



format -w $COLUMNS <<PYF
 libdepend /command/* will show the subroutine library dependancies of all commands in
 /command... 

 Recall that you can scroll back at a pause with shift&pageup.






PYF

read JUNK

if test "$JUNK" != "s" ;
then {

libdepend /command/*
};
fi


echo "cLIeNUX guide"
echo
echo
format -w $COLUMNS <<PYF
 Recall again that you can scroll your terminal back with shift&page_up,
 or hit enter to continue.
PYF

read JUNK
clear
stc



echo 
echo "cLIeNUX guide"

format -w $COLUMNS <<BLHA
 Now lets see if the C compiler, GNU cc or gcc, works. Note that if it doesn't 
 then this script is more likely to be at fault than gcc. This will 
 take some fancy scripting (and requires superuser perms)...... 
BLHA

read JUNK
## may need some help to run from init

COMPILER_PATH=":/owner/command:/command:/command/background:/command/alias/:/command/background/C/"

LIBRARY_PATH=/.li/:/subroutine/:/.us/.li/:/subroutine/static/

cat    <<-HEREDOC  > xfxfxfx.c
#include <stdio.h>
int main(){
     	printf("YES! This text is the output of a new executable\n ");
	printf("that was written in C, compiled, run, and removed\n ");
	printf("just now by this script.\n\n\n");
     	return 0;
          }
HEREDOC

cc  -o xfxfxfxfx xfxfxfx.c
permit +x xfxfxfxfx
./xfxfxfxfx
rm xfxfxfxfx xfxfxfx.c

read JUNK
clear 
stc

echo
echo "cLIeNUX guide"
echo
format -w $COLUMNS <<BLA

 cLIeNUX Core means a cLIeNUX with everything needed to
 continue to build your cLIeNUX from sourcecode. THAT means 
 that from Core further additions are not necessarily
 platform-specific. THAT means Core includes a compiler, and an
 assembler for your box. cLIeNUX Core has 2 compilers, gcc 
 without c++ etc., and an ANSI Forth. pForth probably.
 I'm going to stick you in the Forth interpreter. You can leave it
 with the Forth word   bye  . Tell it   words     before you leave,
 just for grins, or    3  4   +  .      (with the period)"
BLA
read JUNK
if test "$JUNK" != "s" ;
then {

forth;
} 
fi

clear
stc


echo
echo "cLIeNUX guide"
echo
format -w $COLUMNS <<THD
 unix is about a unified filesytem namespace. "Everything is a
 file." Almost everything has a full pathname under   /  somewhere.
 The flexibility this gives is wondrous. The downside is that things
 like floppies have to be "mounted" on a free mountpoint somewhere
 in the overall filesystem under  /  . The   mount   command does
 this. You'll be dealing with /.et/fstab, mount, and /.pro/mounts.
 Here they are.....

THD


read JUNK
if test "$JUNK" != "s" ;
then {

echo "doing    mount    (which reads /.et/mtab for this...)"
mount
echo
echo "this is /linux/mounts ..."
cat /.pro/mounts


read JUNK
clear 
stc

echo    
echo " This is /configure/fstab. fstab is the one you edit for your box. "
echo " mtab is kept by the system."
cat /.et/fstab
};
fi

read JUNK
clear 
stc


echo "cLIeNUX guide"
echo

format -w $COLUMNS <<LIST
 Just for scrollage, let's do    ls --color  /   to see all your 
 files to 2 directories deep. 
 ctrl&c  will send the script an EndOfFile character, killing it, 
 and/or you can pause the scrollage with your "scroll lock" key. 
 The GNU ls builtin coloring scheme cLIeNUX uses for files is.... 
LIST
echo "		white 		default"
echo "		green		directory"
echo "		purple		executable"
echo "		cyan		symbolic link"
echo "		white_on_blue	device special file"
echo "		orange (brown)	pipe"
echo
echo " This script has changed the default colors though."

read JUNK
if test "$JUNK" != "s" ;
then {

ls --color */*
};
fi


echo "cLIeNUX guide"
echo "OK, signing off...."

read JUNK
if test "$JUNK" != "s" ;
then {

view -z /help/ABOUT_cLIeNUX/cLIeNUX.jpg

};
fi

setfont /.et/console/fonts/11
textcolor -r

echo "Break a leg.      :o) "


get <<BLA
Copyright 1999 Richard Allen Hohensee
This file is released for redistribution only as part of an entire intact
cLIeNUX Core.
BLA


