| Author |
Message |
zigbert

Joined: 29 Mar 2006 Posts: 5241 Location: Valåmoen, Norway
|
Posted: Thu 14 Oct 2010, 03:18 Post subject:
|
|
Nathan Fisher did something in between..... He used a case-function in another file (as I do it), but instead of actual writing the code inside the case-function he linked it to functions in the same file. Like this you could (un)fold them AND keep them in another file.
Sigmund
_________________ Stardust resources
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Sat 16 Oct 2010, 22:08 Post subject:
|
|
I have already split the files into 2 for convenience
if you want to use bashbox functions just add:
. /usr/share/bashbox/bbfxns.sh
Here is an updated function list:addgroupgui() { #uses main_dialog() -> #addgroup [-g GID] [user_name] group_name
blockads() { #tweaks /etc/hosts to ban certain sites
brokenlinks() { #find broken links in given input dir or pwd if not given
dirtree() { #show a visualization of directories and files
fixflash() { #mask your flash version as 10.1 rXXXXXX
getflash() { #install latest flash
getflash9() { #flash9 is smaller, fewer deps and still updated
getinput() { #DIALOG box to return user input to stdout
google() { #searches google for $@ or if blank uses $DIALOG
gtkdialog_menu() { #Set up an external menu for your gtkdialog gui
grep "$1() { #" /usr/share/bashbox/bbfxns.sh #list fxn(s)
launcher() { #gtkdialog basic launcher program like gexec + dropdown menu
logstdout() { #usage: logstdout logfile.log command arguments (records normal output)
logstderr() { #usage: logstderr logfile.log command arguments (records error output)
logall() { #usage: logall logfile.log command arguments (records error & normal output)
main_dialog() { #parses template of vars to gen and eval a dialog then return the results
maindialogtemplate() { #example of how to use main_dialog
percentbar() { #usage: "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
pget() { #download $1 to HOME/my-documents with axel
pickdate() { #choose a date - optional input: $1="text" $2=day $3=month $4=year
picktime() { #output a time - optional input: $1="text" $2=hours $3=minutes $4=seconds
pickfile() { #DIALOG box to return a user chosen file to stdout
pickXcolor() { #DIALOG box to return a user chosen X color to stdout
play_au() { #just sends $@ to /dev/audio
play_wav() { #just sends $@ to /dev/dsp
reset_mixers() { #from /usr/sbin/alsaconf... was called from rc.local0.
setDIALOG() { #sets $DIALOG to Xdialog if in X or dialog if in console
setjwmbg() { #TODO tweaks ... include $HOME/.jwmbg in the jwmrc template
setXCOLORS() { #sets $XCOLORS from ...rgb.txt
silent() { #run a command with no output #usage: silent command arguments
silentlog() { #usage: silentlog logfile.log command arguments (records only normal output)
silentlogall() { #usage: silentlogall logfile.log command arguments (records error & normal output)
silentlogerr() { #usage: silentlogerr logfile.log command arguments (records only error output)
test_program_with_LANG() { #$1=LANG followed by command to test
tolower() { #change input $@ to lower case
toupper() { #change input $@ to upper case
tree() { #show a cli visualization of directories and files
tweet() { #send a tweet $1 is username $2 is password "$3" is the tweet (must be in quotes)
webcam2avi() { #capture your webcam to HOME/webcam.avi - requires ffmpeg & rxvt
X2avi() { #capture your desktop to HOME/x11-session.avi - ffmpeg needs x11grab
Xsetvolume() { #set volume with slider
Xshowimage() { #quick view of image
pprocess() { #process manager
ffconvert() { # FFConvert - a frontend of ffmpeg
Edit - tweet needs to be updated for new twitter api - any tweeters want to tackle it?
 |
| Description |
|

Download |
| Filename |
bashbox-0.5.1.pet |
| Filesize |
22.97 KB |
| Downloaded |
343 Time(s) |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Sat 30 Oct 2010, 18:12 Post subject:
|
|
I was testing different build environments for saluki and wanted a way to check the total disk usage including dependencies and came up with these (added a couple similar functions while I was at it)
more functions for next release:
| Code: | addlist(){ #adds a space separated list of numbers
echo $((`echo $@ |tr " " "+"`))
}
multlist(){ #multiplies a space separated list of numbers
echo $((`echo $@ |tr " " "*"`))
}
divide(){ #divide first entry by second
echo $(($1/$2))
}
subtract(){ #subtract second entry from first
echo $(($1-$2))
}
du_deps(){ #returns a space separated list of disk usage including dep libs
for x in `echo $1 && ldd $1 |awk '{print $3 }' |grep -v ")" |grep -v dynamic` ; do du `readlink -f $x` |cut -f1 |tr "\n" " "; done
}
realusage(){ #returns total usage of several apps/libs
for x in $@; do echo $x: && addlist `du_deps $x`; done
}
tot_usage() { #adds up total usage of several apps/libs
echo $@: && addlist `realusage $@ |grep -v ":"`
} |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Sun 31 Oct 2010, 09:57 Post subject:
|
|
I am adding BashBox to my puplet btw.
Feature Request:
With the "webcam2avi()" and the "X2avi()" functions could you add a option too them or a version of them for OGG and/or WebM output please.
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Sun 31 Oct 2010, 11:12 Post subject:
|
|
Here is your in-dev newer version of Woo-FF
| Description |
|

Download |
| Filename |
woo-ff2.bz2 |
| Filesize |
4.34 KB |
| Downloaded |
267 Time(s) |
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Sun 31 Oct 2010, 22:33 Post subject:
|
|
looks good - just need to learn about the lates ffmpeg stuff - I have ported almost everything from the last woof build before Barry just updated it.
TODO
port all programs to use a common _STARTING_ and _PROCESSING_ gui dialog
split out gtkdialog functions into templates for common usage
Edit:
I was thinking that it might be good to just add the option of "Source" to woo-ff (I already have ffconvert included too - so I could add there as well) ... options would be: File, Desktop, Webcam
For desktop and webcam it would need a check to wait for the file (when recording is stopped) and then convert it to the chosen format.
Note: recording directly to a compressed format would likely not work well on a lot of machines.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Mon 01 Nov 2010, 10:12 Post subject:
|
|
| technosaurus wrote: | | Note: recording directly to a compressed format would likely not work well on a lot of machines. | Good point.
Bug:
The getflash function failed to unpack the downloaded archive.
| Code: | # bashbox getflash
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
# |
The text file "/usr/lib/mozilla/plugins/-" was created with this contents:
| Code: | --23:11:18-- http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
=> `install_flash_player_10_linux.tar.gz'
Resolving fpdownload.macromedia.com... 2.19.210.70
Connecting to fpdownload.macromedia.com|2.19.210.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4,907,056 (4.7M) [application/x-gzip]
0K .......... .......... .......... .......... .......... 1% 178.67 KB/s
50K .......... .......... .......... .......... .......... 2% 174.48 KB/s
100K .......... .......... .......... .......... .......... 3% 179.09 KB/s
150K .......... .......... .......... .......... .......... 4% 179.26 KB/s
200K .......... .......... .......... .......... .......... 5% 174.36 KB/s
250K .......... .......... .......... .......... .......... 6% 179.10 KB/s
300K .......... .......... .......... .......... .......... 7% 174.47 KB/s
350K .......... .......... .......... .......... .......... 8% 179.10 KB/s
400K .......... .......... .......... .......... .......... 9% 179.26 KB/s
450K .......... .......... .......... .......... .......... 10% 174.39 KB/s
500K .......... .......... .......... .......... .......... 11% 179.06 KB/s
550K .......... .......... .......... .......... .......... 12% 174.47 KB/s
600K .......... .......... .......... .......... .......... 13% 179.11 KB/s
650K .......... .......... .......... .......... .......... 14% 174.37 KB/s
700K .......... .......... .......... .......... .......... 15% 179.29 KB/s
750K .......... .......... .......... .......... .......... 16% 179.06 KB/s
800K .......... .......... .......... .......... .......... 17% 174.41 KB/s
850K .......... .......... .......... .......... .......... 18% 179.17 KB/s
900K .......... .......... .......... .......... .......... 19% 174.36 KB/s
950K .......... .......... .......... .......... .......... 20% 179.29 KB/s
1000K .......... .......... .......... .......... .......... 21% 179.26 KB/s
1050K .......... .......... .......... .......... .......... 22% 174.31 KB/s
1100K .......... .......... .......... .......... .......... 23% 179.10 KB/s
1150K .......... .......... .......... .......... .......... 25% 174.33 KB/s
1200K .......... .......... .......... .......... .......... 26% 179.31 KB/s
1250K .......... .......... .......... .......... .......... 27% 174.32 KB/s
1300K .......... .......... .......... .......... .......... 28% 179.24 KB/s
1350K .......... .......... .......... .......... .......... 29% 179.11 KB/s
1400K .......... .......... .......... .......... .......... 30% 174.33 KB/s
1450K .......... .......... .......... .......... .......... 31% 179.30 KB/s
1500K .......... .......... .......... .......... .......... 32% 174.30 KB/s
1550K .......... .......... .......... .......... .......... 33% 179.27 KB/s
1600K .......... .......... .......... .......... .......... 34% 179.11 KB/s
1650K .......... .......... .......... .......... .......... 35% 174.35 KB/s
1700K .......... .......... .......... .......... .......... 36% 178.08 KB/s
1750K .......... .......... .......... .......... .......... 37% 175.31 KB/s
1800K .......... .......... .......... .......... .......... 38% 179.26 KB/s
1850K .......... .......... .......... .......... .......... 39% 179.09 KB/s
1900K .......... .......... .......... .......... .......... 40% 174.35 KB/s
1950K .......... .......... .......... .......... .......... 41% 179.26 KB/s
2000K .......... .......... .......... .......... .......... 42% 174.36 KB/s
2050K .......... .......... .......... .......... .......... 43% 179.25 KB/s
2100K .......... .......... .......... .......... .......... 44% 174.33 KB/s
2150K .......... .......... .......... .......... .......... 45% 179.10 KB/s
2200K .......... .......... .......... .......... .......... 46% 15.52 KB/s
2250K .......... .......... .......... .......... .......... 47% 230.33 KB/s
2300K .......... .......... .......... .......... .......... 49% 645.80 KB/s
2350K .......... .......... .......... .......... .......... 50% 195.46 MB/s
2400K .......... .......... .......... .......... .......... 51% 300.43 MB/s
2450K .......... .......... .......... .......... .......... 52% 282.81 MB/s
2500K .......... .......... .......... .......... .......... 53% 285.77 MB/s
2550K .......... .......... .......... .......... .......... 54% 292.19 MB/s
2600K .......... .......... .......... .......... .......... 55% 316.09 KB/s
2650K .......... .......... .......... .......... .......... 56% 230.58 KB/s
2700K .......... .......... .......... .......... .......... 57% 174.19 KB/s
2750K .......... .......... .......... .......... .......... 58% 307.18 KB/s
2800K .......... .......... .......... .......... .......... 59% 260.98 MB/s
2850K .......... .......... .......... .......... .......... 60% 279.78 MB/s
2900K .......... .......... .......... .......... .......... 61% 295.59 MB/s
2950K .......... .......... .......... .......... .......... 62% 281.68 KB/s
3000K .......... .......... .......... .......... .......... 63% 179.13 KB/s
3050K .......... .......... .......... .......... .......... 64% 174.37 KB/s
3100K .......... .......... .......... .......... .......... 65% 179.08 KB/s
3150K .......... .......... .......... .......... .......... 66% 179.09 KB/s
3200K .......... .......... .......... .......... .......... 67% 174.51 KB/s
3250K .......... .......... .......... .......... .......... 68% 179.11 KB/s
3300K .......... .......... .......... .......... .......... 69% 174.35 KB/s
3350K .......... .......... .......... .......... .......... 70% 179.26 KB/s
3400K .......... .......... .......... .......... .......... 71% 174.32 KB/s
3450K .......... .......... .......... .......... .......... 73% 179.25 KB/s
3500K .......... .......... .......... .......... .......... 74% 179.10 KB/s
3550K .......... .......... .......... .......... .......... 75% 174.35 KB/s
3600K .......... .......... .......... .......... .......... 76% 179.28 KB/s
3650K .......... .......... .......... .......... .......... 77% 174.31 KB/s
3700K .......... .......... .......... .......... .......... 78% 179.27 KB/s
3750K .......... .......... .......... .......... .......... 79% 179.09 KB/s
3800K .......... .......... .......... .......... .......... 80% 174.33 KB/s
3850K .......... .......... .......... .......... .......... 81% 179.31 KB/s
3900K .......... .......... .......... .......... .......... 82% 174.31 KB/s
3950K .......... .......... .......... .......... .......... 83% 179.26 KB/s
4000K .......... .......... .......... .......... .......... 84% 174.32 KB/s
4050K .......... .......... .......... .......... .......... 85% 179.11 KB/s
4100K .......... .......... .......... .......... .......... 86% 179.30 KB/s
4150K .......... .......... .......... .......... .......... 87% 174.31 KB/s
4200K .......... .......... .......... .......... .......... 88% 179.27 KB/s
4250K .......... .......... .......... .......... .......... 89% 174.33 KB/s
4300K .......... .......... .......... .......... .......... 90% 179.10 KB/s
4350K .......... .......... .......... .......... .......... 91% 179.29 KB/s
4400K .......... .......... .......... .......... .......... 92% 174.32 KB/s
4450K .......... .......... .......... .......... .......... 93% 179.25 KB/s
4500K .......... .......... .......... .......... .......... 94% 174.33 KB/s
4550K .......... .......... .......... .......... .......... 95% 179.11 KB/s
4600K .......... .......... .......... .......... .......... 97% 174.53 KB/s
4650K .......... .......... .......... .......... .......... 98% 179.08 KB/s
4700K .......... .......... .......... .......... .......... 99% 179.25 KB/s
4750K .......... .......... .......... .......... .. 100% 177.84 KB/s
23:11:46 (177.16 KB/s) - `install_flash_player_10_linux.tar.gz' saved [4907056/4907056]
|
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Tue 16 Nov 2010, 09:48 Post subject:
|
|
Here is the fix for the Flash get functions.
| Code: | getflash() { #install latest flash
cd /usr/lib/mozilla/plugins
wget -c http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar -xzf install_flash_player_10_linux.tar.gz
rm -f install_flash_player_10_linux.tar.gz
}
getflash9() { #flash9 is smaller, fewer deps and still updated
cd /usr/lib/mozilla/plugins
wget -c http://download.macromedia.com/pub/flashplayer/installers/current/9/install_flash_player_9.tar.gz
rm -f install_flash_player_9.tar.gz
} |
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Tue 16 Nov 2010, 11:11 Post subject:
|
|
Thanks
missed:
tar -xzf install_flash_player_9.tar.gz
The piping method worked fine for me (I may? have modified it though) ... though it temporarily saves space in ram/save file (only 4-5MB), it may? be dependent on having a decent net connection or version of tar.
I will post a new version with lots of extras soon. It already includes _some_ P-programs, some goodies from other small distros and almost all busybox compatible woof scripts. For testing purposes, I want to release it in conjuction with a FULL busybox with lots of extra addons (old_e2fstools, minimp3, checkfstype, autologinroot, ... pretty much everything in the initramfs and some useful extras ... except ntfs-3g - its a PITA to port) <I want to see if hush is ready to replace ash - Rob Landley already has in aboriginal, but mainly I think to support no-mmu platforms> ... I have hush aliased to sh and ash aliased to bash for the time being.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Tue 16 Nov 2010, 12:18 Post subject:
|
|
opps , thanks for pointing out.
tar version:
| Code: | # tar --version
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
# |
Will the new version/Full BusyBox work on my current base of ttuuxxx's 4.3.2 v3 or will it work on these puplets: 4.3.2 SCSI-001, Wary, Lupu, Fluppy, Light House Pup, Quirky, etc?
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Tue 16 Nov 2010, 16:24 Post subject:
|
|
Just got another idea for a useful script based on genhbar (gengraph)
basic idea use sed (or a bash trick?) to remove the first column of "pixels" and add a column on the end (remove first character of a string/line and add one at the end)
- useful for generating a graph (cpu usage comes to mind)
I compile busybox statically against uclibc using Rob Landley's toolkit, so it should run on any 586+ linux.... as to "working" I'm pretty sure busybox has a similar disclaimer.
... that reminds me I have been meaning to work on a patch for busybox to allow extra LDFLAGS - currently I have to run make as follows:
#Q prepends the make calls for silent output - this overrides it
then I copy the line that builds the busybox binary and add my LDFLAGS manually (mainly for --gc-sections)
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Mon 07 Feb 2011, 03:23 Post subject:
|
|
I've been adding functions fairly regularly over the last few months:
All woof scripts just for testing ...need to pull some or update
Some p.apps , will remove unless devs are willing to support
Various helper functions ... play au, wav files, strip scripts, calculator, dirtree,...
I'll put out a 1.0 alpha based on these additions, but am already planning for a 2.x series.
Here is the todo list:
Make it portable to other distros.
Help other devs port their apps (so they work with bashbox and other distros)
Split out apps that can use busybox applets so they run 2000% faster.
Better comments in the development version with a script that pulls them into a doc file for release (for start speed)
Wrappers for dialogs where necessary and possible (xdialog, dialog, getgui, gtkdialog, yafsplash,... better portability)
This will add 1 file called ashbox for compliant functions (I consider the others to be in development... hopefully to end up getting compliant to busybox applets where possible ... I have already ported several)
Google code now allows direct editing, I will be using it so that developers can easily update their apps with a quick cut and paste.
I did do some testing for speed and the load time for the script with all the functions is less than the time to load just 1 additional small script... so I'm not all that worried about that aspect.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Wed 09 Feb 2011, 13:43 Post subject:
|
|
I don't know how many puppy users are using busybox httpd as a web server with ash/hush for cgi scripts, but I know it is quite popular, so I am trying to add some simple and common cgi scripts and have started a framework for establishing a basic dynamic GUI (similar to gtkdialog) ... even better it should allow you to do things like setup networking and other administrative tasks directly from the browser... should have a pre alpha version soon (but no enhanced security _yet_)
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Wed 09 Feb 2011, 18:31 Post subject:
|
|
here are some of the webgui generator functions to use in cgi scripts - still a work in progress
| Code: | #need to add some backslashed quotes in case of multiword inputs
htmlchecheckbox() { # generate a checkbox $1=name followed by a value
echo "<input type=checkbox name=$1 value=$2 />$2"
}
htmlcombobox() { # generate a dropdown list $1=name followed by a list of values
echo "<select name=${1:-combobox}>"
shift
for x in $@ do echo "<option value=$1>$1</option>"; done
echo "</select>"
}
htmldeflist() { # word1 "the definition" word2 "....
echo "<dl>"
while $1 do
echo "<dt>$1</dt><dd>$2</dd>"
shift 2
done
echo "</dl>"
}
htmlentry() { # generate entry box $1=name ...default value?
echo "<input type=text name=${1:-entry} />"
}
htmlformbegin() {
echo "<form action=cgi-bin/ashbox.cgi method=get>"
}
htmlformend() {
echo "</form>"
}
htmlframebegin() {
echo "<fieldset><legend>${1:-frame}</legend>"
}
htmlframeend() {
echo "</fieldset>"
}
htmlheader() { #$1=title $2=stylesheet $3=background image
echo "<html><head><title>${1:-PleaseAddTitle}</title><link rel="stylesheet" href=${2:-stylsheet.css}></head><body alink=#ff0000 background=${3:-background.jpg} bgcolor=#ffffff link=#0000ff text=#000000 vlink=#ff00ff><img src=${3:-background.jpg} alt=${3:-background.jpg} id=bg>"
}
htmlpassword() { # generate password box $1=name
echo "<input type=password name=${1:-pwd} />"
}
htmlradiobutton() { # generate radio buttons $1=name followed by a value
echo "<input type=radio name=${2:-radio} value=$1 />$1";done
}
htmlsubmitbuttonimage() { #todo
}
htmlsubmitbuttontext() {
echo "<input type=submit value=$1 />"
}
htmltextarea() { # generate a text area $1rows high by $2 cols wide followed by default text
ROWS=$1;COLS=$2;shift 2 #Note row and column can also be %
echo "<textarea rows=$ROWS cols=$COLS>$@</textarea>"
}
htmltext() { # $@ is text
echo "<pre>$@</pre>" |tr "\n" "\\" |sed 's/\\/"<br>"/g' #need to check & improve this
}
htmlparsequerystring() { #parse the query string to get VAR (VAR==$1) from var=param (var==$2)
$1=`echo "$QUERY_STRING" | sed -n 's/^.*$2=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
#may need an eval of $1 ???
}
htmlimage() { #show an image $1=image $2=hyperlink $3=alt_text $4=height $5=width....
echo "<img src=$1 height=$4 width=$5 />" #todo
} |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Fri 11 Mar 2011, 17:20 Post subject:
|
|
some notes on substring manipulation
| Code: | change_ext() { #change_ext .old .new <files>
old=$1
new=$2
shift 2
for x in $@ do
mv -f $x ${x%.$old}.$new ##OR## ${x/%$old/$new}
done
}
#example:
change_ext tgz tar.gz `ls *.tgz 2>&1`
defaulthandler() {
ext=${1#*.}
case $ext in
cgi)cgi $1 #TODO add cgi(){ #check for httpd running ... }
*)rox $1;; #rox will do most of this now ... including urls
esac
}
basename() {
echo "${1##*/}"
}
dirname() {
echo "${1%/*}"
}
# "pointers" in bash
abc23=something_else
b=${!abc*}
echo "b = $b" # b = abc23
c=${!b} # Now, the more familiar type of indirect reference.
echo $c # something_else
# ... combine this with arrays for something quite useful |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
|