This commit is contained in:
gferg 2007-04-26 21:14:20 +00:00
parent bf1977cfef
commit 9853b20e0f
4 changed files with 545 additions and 0 deletions

View File

@ -0,0 +1,64 @@
#!/bin/bash
# find-splitpara.sh
# Finds split paragraphs in a text file,
#+ and tags the line numbers.
ARGCOUNT=1 # Expect one arg.
E_WRONGARGS=65
file="$1" # Target filename.
lineno=1 # Line number. Start at 1.
Flag=0 # Blank line flag.
if [ $# -ne "$ARGCOUNT" ]
then
echo "Usage: `basename $0` FILENAME"
exit $E_WRONGARGS
fi
file_read () # Scan file for pattern, then print line.
{
while read line
do
if [[ "$line" =~ ^[a-z] && $Flag -eq 1 ]]
then # Line begins with lc character, following blank line.
echo -n "$lineno:: "
echo "$line"
fi
if [[ "$line" =~ "^$" ]]
then # If blank line,
Flag=1 #+ set flag.
else
Flag=0
fi
((lineno++))
done
} < $file # Redirect file into function's stdin.
file_read
exit $?
# ----------------------------------------------------------------
This is line one of an example paragraph, bla, bla, bla.
This is line two, and line three should follow on next line, but
there is a blank line separating the two parts of the paragraph.
# ----------------------------------------------------------------
Running this script on a file containing the above paragraph
yields:
4:: there is a blank line separating the two parts of the paragraph.
There will be additional output for all the other split paragraphs
in the target file.

View File

@ -0,0 +1,243 @@
#!/bin/bash
# pad.sh
######################################################
# PAD (xml) file creator
#+ Written by Mendel Cooper &lt;thegrendel@theriver.com&gt;.
#+ Released to the Public Domain.
#
# Generates a "PAD" descriptor file for shareware
#+ packages, according to the specifications
#+ of the ASP.
# http://www.asp-shareware.org/pad
######################################################
# Accepts (optional) save filename as a command-line argument.
if [ -n "$1" ]
then
savefile=$1
else
savefile=save_file.xml # Default save_file name.
fi
# ===== PAD file headers =====
HDR1="&lt;?xml version=\"1.0\" encoding=\"Windows-1252\" ?&gt;"
HDR2="&lt;XML_DIZ_INFO&gt;"
HDR3="&lt;MASTER_PAD_VERSION_INFO&gt;"
HDR4="\t&lt;MASTER_PAD_VERSION&gt;1.15&lt;/MASTER_PAD_VERSION&gt;"
HDR5="\t&lt;MASTER_PAD_INFO&gt;Portable Application Description, or PAD
for short, is a data set that is used by shareware authors to
disseminate information to anyone interested in their software products.
To find out more go to http://www.asp-shareware.org/pad&lt;/MASTER_PAD_INFO&gt;"
HDR6="&lt;/MASTER_PAD_VERSION_INFO&gt;"
# ============================
fill_in ()
{
if [ -z "$2" ]
then
echo -n "$1? " # Get user input.
else
echo -n "$1 $2? " # Additional query?
fi
read var # May paste to fill in field.
# This shows how flexible "read" can be.
if [ -z "$var" ]
then
echo -e "\t\t<$1 />" >>$savefile # Indent with 2 tabs.
return
else
echo -e "\t\t<$1>$var</$1>" >>$savefile
return ${#var} # Return length of input string.
fi
}
check_field_length () # Check length of program description fields.
{
# $1 = maximum field length
# $2 = actual field length
if [ "$2" -gt "$1" ]
then
echo "Warning: Maximum field length of $1 characters exceeded!"
fi
}
clear # Clear screen.
echo "PAD File Creator"
echo "--- ---- -------"
echo
# Write File Headers to file.
echo $HDR1 >$savefile
echo $HDR2 >>$savefile
echo $HDR3 >>$savefile
echo -e $HDR4 >>$savefile
echo -e $HDR5 >>$savefile
echo $HDR6 >>$savefile
# Company_Info
echo "COMPANY INFO"
CO_HDR="Company_Info"
echo "<$CO_HDR>" >>$savefile
fill_in Company_Name
fill_in Address_1
fill_in Address_2
fill_in City_Town
fill_in State_Province
fill_in Zip_Postal_Code
fill_in Country
# If applicable:
# fill_in ASP_Member "[Y/N]"
# fill_in ASP_Member_Number
# fill_in ESC_Member "[Y/N]"
fill_in Company_WebSite_URL
clear # Clear screen between sections.
# Contact_Info
echo "CONTACT INFO"
CONTACT_HDR="Contact_Info"
echo "<$CONTACT_HDR>" >>$savefile
fill_in Author_First_Name
fill_in Author_Last_Name
fill_in Author_Email
fill_in Contact_First_Name
fill_in Contact_Last_Name
fill_in Contact_Email
echo -e "\t</$CONTACT_HDR>" >>$savefile
# END Contact_Info
clear
# Support_Info
echo "SUPPORT INFO"
SUPPORT_HDR="Support_Info"
echo "<$SUPPORT_HDR>" >>$savefile
fill_in Sales_Email
fill_in Support_Email
fill_in General_Email
fill_in Sales_Phone
fill_in Support_Phone
fill_in General_Phone
fill_in Fax_Phone
echo -e "\t</$SUPPORT_HDR>" >>$savefile
# END Support_Info
echo "</$CO_HDR>" >>$savefile
# END Company_Info
clear
# Program_Info
echo "PROGRAM INFO"
PROGRAM_HDR="Program_Info"
echo "<$PROGRAM_HDR>" >>$savefile
fill_in Program_Name
fill_in Program_Version
fill_in Program_Release_Month
fill_in Program_Release_Day
fill_in Program_Release_Year
fill_in Program_Cost_Dollars
fill_in Program_Cost_Other
fill_in Program_Type "[Shareware/Freeware/GPL]"
fill_in Program_Release_Status "[Beta, Major Upgrade, etc.]"
fill_in Program_Install_Support
fill_in Program_OS_Support "[Win9x/Win2k/Linux/etc.]"
fill_in Program_Language "[English/Spanish/etc.]"
echo; echo
# File_Info
echo "FILE INFO"
FILEINFO_HDR="File_Info"
echo "<$FILEINFO_HDR>" >>$savefile
fill_in Filename_Versioned
fill_in Filename_Previous
fill_in Filename_Generic
fill_in Filename_Long
fill_in File_Size_Bytes
fill_in File_Size_K
fill_in File_Size_MB
echo -e "\t</$FILEINFO_HDR>" >>$savefile
# END File_Info
clear
# Expire_Info
echo "EXPIRE INFO"
EXPIRE_HDR="Expire_Info"
echo "<$EXPIRE_HDR>" >>$savefile
fill_in Has_Expire_Info "Y/N"
fill_in Expire_Count
fill_in Expire_Based_On
fill_in Expire_Other_Info
fill_in Expire_Month
fill_in Expire_Day
fill_in Expire_Year
echo -e "\t</$EXPIRE_HDR>" >>$savefile
# END Expire_Info
clear
# More Program_Info
echo "ADDITIONAL PROGRAM INFO"
fill_in Program_Change_Info
fill_in Program_Specific_Category
fill_in Program_Categories
fill_in Includes_JAVA_VM "[Y/N]"
fill_in Includes_VB_Runtime "[Y/N]"
fill_in Includes_DirectX "[Y/N]"
# END More Program_Info
echo "</$PROGRAM_HDR>" >>$savefile
# END Program_Info
clear
# Program Description
echo "PROGRAM DESCRIPTIONS"
PROGDESC_HDR="Program_Descriptions"
echo "<$PROGDESC_HDR>" >>$savefile
LANG="English"
echo "<$LANG>" >>$savefile
fill_in Keywords "[comma + space separated]"
echo
echo "45, 80, 250, 450, 2000 word program descriptions"
echo "(may cut and paste into field)"
# It would be highly appropriate to compose the following
#+ "Char_Desc" fields with a text editor,
#+ then cut-and-paste the text into the answer fields.
echo
echo " |---------------45 characters---------------|"
fill_in Char_Desc_45
check_field_length 45 "$?"
echo
fill_in Char_Desc_80
check_field_length 80 "$?"
fill_in Char_Desc_250
check_field_length 250 "$?"
fill_in Char_Desc_450
fill_in Char_Desc_2000
echo "</$LANG>" >>$savefile
echo "</$PROGDESC_HDR>" >>$savefile
# END Program Description
clear
echo "Done."; echo; echo
echo "Save file is: \""$savefile"\""
exit 0

View File

@ -0,0 +1,106 @@
#!/bin/bash
# soundcard-on.sh
# Script author: Mkarcher
# http://www.thinkwiki.org/wiki ...
# /Script_for_configuring_the_CS4239_sound_chip_in_PnP_mode
# ABS Guide author made minor changes and added comments.
# Couldn't contact script author to ask for permission to use, but ...
#+ the script was released under the FDL,
#+ so its use here should be both legal and ethical.
# Sound-via-pnp-script for Thinkpad 600E
#+ and possibly other computers with onboard CS4239/CS4610
#+ that do not work with the PCI driver
#+ and are not recognized by the PnP code of snd-cs4236.
# Also for some 770-series Thinkpads, such as the 770x.
# Run as root user, of course.
#
# These are old and very obsolete laptop computers,
#+ but this particular script is very instructive,
#+ as it shows how to set up and hack device files.
# Search for sound card pnp device:
for dev in /sys/bus/pnp/devices/*
do
grep CSC0100 $dev/id > /dev/null && WSSDEV=$dev
grep CSC0110 $dev/id > /dev/null && CTLDEV=$dev
done
# On 770x:
# WSSDEV = /sys/bus/pnp/devices/00:07
# CTLDEV = /sys/bus/pnp/devices/00:06
# These are symbolic links to /sys/devices/pnp0/ ...
# Activate devices:
# Thinkpad boots with devices disabled unless "fast boot" is turned off
#+ (in BIOS).
echo activate > $WSSDEV/resources
echo activate > $CTLDEV/resources
# Parse resource settings.
{ read # Discard "state = active" (see below).
read bla port1
read bla port2
read bla port3
read bla irq
read bla dma1
read bla dma2
# The "bla's" are labels in the first field: "io," "state," etc.
# These are discarded.
# Hack: with PnPBIOS: ports are: port1: WSS, port2:
#+ OPL, port3: sb (unneeded)
# with ACPI-PnP:ports are: port1: OPL, port2: sb, port3: WSS
# (ACPI bios seems to be wrong here, the PnP-card-code in snd-cs4236.c
#+ uses the PnPBIOS port order)
# Detect port order using the fixed OPL port as reference.
if [ ${port2%%-*} = 0x388 ]
# ^^^^ Strip out everything following hyphen in port address.
# So, if port1 is 0x530-0x537
#+ we're left with 0x530 -- the start address of the port.
then
# PnPBIOS: usual order
port=${port1%%-*}
oplport=${port2%%-*}
else
# ACPI: mixed-up order
port=${port3%%-*}
oplport=${port1%%-*}
fi
} < $WSSDEV/resources
# To see what's going on here:
# ---------------------------
# cat /sys/devices/pnp0/00:07/resources
#
# state = active
# io 0x530-0x537
# io 0x388-0x38b
# io 0x220-0x233
# irq 5
# dma 1
# dma 0
# ^^^ "bla" labels in first field (discarded).
{ read # Discard first line, as above.
read bla port1
cport=${port1%%-*}
# ^^^^
# Just want _start_ address of port.
} < $CTLDEV/resources
# Load the module:
modprobe --ignore-install snd-cs4236 port=$port cport=$cport\
fm_port=$oplport irq=$irq dma1=$dma1 dma2=$dma2 isapnp=0 index=0
# See the modprobe manpage.
exit $?

View File

@ -0,0 +1,132 @@
#!/bin/bash
# tohtml.sh
# Convert a text file to HTML format.
# Author: Mendel Cooper
# License: GPL3
# Usage: sh tohtml.sh < textfile > htmlfile
# Script can easily be modified to accept source and target filenames.
# Assumptions:
# 1) Paragraphs in (target) text file are separated by a blank line.
# 2) Jpeg images (*.jpg) are located in "images" subdirectory.
# 3) Emphasized (italic) phrases begin with a space+underscore
#+ or are the first character on the line,
#+ and end with an underscore+space or underscore+end-of-line.
# Settings
FNTSIZE=2 # Small-medium font size
IMGDIR="images" # Image directory
# Headers
HDR01='&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;'
HDR02='&lt;!-- Converted to HTML by ***tohtml.sh*** script --&gt;'
HDR03='&lt;!-- script author: M. Leo Cooper &lt;thegrendel@theriver.com&gt; --&gt;'
HDR10='&lt;html&gt;'
HDR11='&lt;head&gt;'
HDR11a='&lt;/head&gt;'
HDR12a='&lt;title&gt;'
HDR12b='&lt;/title&gt;'
HDR121='&lt;META NAME="GENERATOR" CONTENT="tohtml.sh script"&gt;'
HDR13='&lt;body bgcolor="#dddddd"&gt;' # Change background color to suit.
HDR14a='&lt;font size='
HDR14b='&gt;'
# Footers
FTR10='&lt;/body&gt;'
FTR11='&lt;/html&gt;'
# Tags
BOLD="&lt;b&gt;"
CENTER="&lt;center&gt;"
END_CENTER="&lt;/center&gt;"
LF="&lt;br&gt;"
write_headers ()
{
echo "$HDR01"
echo
echo "$HDR02"
echo "$HDR03"
echo
echo
echo "$HDR10"
echo "$HDR11"
echo "$HDR121"
echo "$HDR11a"
echo "$HDR13"
echo
echo -n "$HDR14a"
echo -n "$FNTSIZE"
echo "$HDR14b"
echo
echo "$BOLD" # Everything in bold (more easily readable).
}
process_text ()
{
while read line # Read one line at a time.
do
{
if [ ! "$line" ] # Blank line?
then # Then new paragraph must follow.
echo
echo "$LF" # Insert two &lt;br&gt; tags.
echo "$LF"
echo
continue # Skip the underscore test.
else # Otherwise . . .
if [[ "$line" =~ "\[*jpg\]" ]] # Is a graphic?
then # Strip away brackets.
temp=$( echo "$line" | sed -e 's/\[//' -e 's/\]//' )
line=""$CENTER" &lt;img src="\"$IMGDIR"/$temp\"&gt; "$END_CENTER" "
# Add image tag.
# And, center it.
fi
fi
echo "$line" | grep -q _
if [ "$?" -eq 0 ] # If line contains underscore ...
then
# ===================================================
# Convert underscored phrase to italics.
temp=$( echo "$line" |
sed -e 's/ _/ &lt;i&gt;/' -e 's/_ /&lt;\/i&gt; /' |
sed -e 's/^_/&lt;i&gt;/' -e 's/_$/&lt;\/i&gt;/' )
# Process only underscores prefixed by space,
#+ followed by space, or at beginning or end of line.
# Do not convert underscores embedded within a word!
line="$temp"
# Slows script execution. Can be optimized?
# ===================================================
fi
echo
echo "$line"
echo
} # End while
done
} # End process_text ()
write_footers () # Proper termination tags.
{
echo "$FTR10"
echo "$FTR11"
}
# main () {
# =========
write_headers
process_text
write_footers
# =========
# }
exit $?