bashbox: multicall bash script

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#21 Post by technosaurus »

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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#22 Post by abushcrafter »

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: Select all

# 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: Select all

--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]
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
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/

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#23 Post by abushcrafter »

Here is the fix for the Flash get functions.

Code: Select all

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
}
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
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/

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#24 Post by technosaurus »

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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#25 Post by abushcrafter »

opps :oops:, thanks for pointing out.

tar version:

Code: Select all

# 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?
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
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/

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#26 Post by technosaurus »

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

Code: Select all

Q="" make
then I copy the line that builds the busybox binary and add my LDFLAGS manually (mainly for --gc-sections)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#27 Post by technosaurus »

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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#28 Post by technosaurus »

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_)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#29 Post by technosaurus »

here are some of the webgui generator functions to use in cgi scripts - still a work in progress

Code: Select all

#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
}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#30 Post by technosaurus »

some notes on substring manipulation

Code: Select all

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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#31 Post by 2lss »

technosaurus wrote:just save this into a script to test the dir_tree portion

Code: Select all

#!/bin/sh 
DIR=$1 
[ $2 ] && SPACING=$2 || SPACING="|" 
for x in `ls $DIR`; do 
[ -d $DIR/$x ] &&  echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING  " 
done
Sorry to get off subject, but this would work for me. Only problem is when there is a space in the filename.

'for' splits the input by line, and any file name with a space in it throws it off.

Normally I would use double quotes around a variable to prevent this, but with the for/next loop I am not sure.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#32 Post by technosaurus »

as an alternative you can simply use

Code: Select all

DIR=${1:-`pwd`}
SPACING=${2:-|}
cd $DIR
for x in * ; do
[ -d $DIR/$x ] &&  echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING  " 
done
I think it will keep the spaces (not on a *nix box, but I think I may have already done similar in dev)

EDIT ... needed to cd to $DIR for this way to work

I also have an efficient recursive space replace script in the dev version if you are interested, but I don't keep files with spaces around, so not well tested - just 1-2 sub-directories or so. It only requires mv (not sed awk or grep as others do - it uses only the shell's internal substring manipulation - resulting in ~1000% speed improvement)

... right now I don't have a net connection at home so I'm trying to work on a dialog/Xdialog wrapper, so that scripts work independent of X/console (I think goingnuts may have done some work on this already?)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#33 Post by 2lss »

technosaurus wrote:as an alternative you can simply use

Code: Select all

DIR=${1:-`pwd`}
SPACING=${2:-|}
cd $DIR
for x in * ; do
[ -d $DIR/$x ] &&  echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING  " 
done
I think it will keep the spaces (not on a *nix box, but I think I may have already done similar in dev)

EDIT ... needed to cd to $DIR for this way to work
I gave this a try. Unfortunately there is still a problem. When the file or directory is evaluated by [ -d $DIR/$x ] if there is a space the test will throw an error. Quoting $DIR/$x causes the test to always fail. I think cd $DIR needs double quotes as well.

I will give the dev version a shot and see how it works.

EDIT: Which version is the dev version?
technosaurus wrote: It only requires mv (not sed awk or grep as others do - it uses only the shell's internal substring manipulation - resulting in ~1000% speed improvement)
Thats pretty awesome. I never put much thought into the performance aspect of shell scripting.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#34 Post by technosaurus »

I'll have to upload a new DEV version, but I need to transfer it to my droid or go find a hotspot somewhere (it may be a day or 2). My wife has our Altel internet stuff with her in Illinois.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#35 Post by technosaurus »

Just revisiting this to see if anyone is interested in something along these lines in the next generation of Puppy.

another random snippet.

Code: Select all

lsof(){
	for pid in /proc/[0-9]*; do
		exe=$(readlink $pid/exe)
		for fd in $pid/fd/*; do
			fd=$(readlink $fd)
			[ ${#fd} -lt 55 ] && printf " %-55s  %s\n" "$fd" "$exe" || \
			printf " %s ... %s  %s\n" ${fd:0:20} ${fd:$((${#fd}-30)):30} "$exe"
		done
	done |sort -u
}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#36 Post by sc0ttman »

technosaurus wrote:Just revisiting this to see if anyone is interested in something along these lines in the next generation of Puppy.

another random snippet.

Code: Select all

lsof(){
	for pid in /proc/[0-9]*; do 
		for fd in $pid/fd/*; do
			fd=$(readlink $fd)
			[ ${#fd} -lt 55 ] && printf " %-55s  %s\n" "$fd" $(readlink $pid/exe) || \
			printf " %s ... %s  %s\n" ${fd:0:20} ${fd:$((${#fd}-30)):30} $(readlink $pid/exe)
		done
	done |sort -u
}
In puppy4 (maybe later versions) there was a 'pup4funcs' script or something ... it was sourced by many other scripts but never of much use to me in my scripts...

.. what would be *awesome* would be a directory of useful/repeatedly used scripts & funcs in /etc/* or /usr/lib/puppy/, that could be included in other stuff by puppy devs (and puppy itself, in its system scripts etc) .. this would reduce coding time, reduce redundant code in puppy userspace, reduce duplicate code, ease maintaining important system functions and features, and make it easier for newbies to start coding useful, safe, reliable apps of their own...

.. example funcs would include a lot of the funcs you wrote in bashbox

.. One reason to do this would be that Barry wrote pupdialog - then goingnuts, and myself, and others, also coded X/no-X UIs ... So a little library we could *all* use for this would be great..

For another (weak) example, we could have a file, /usr/lib/puppy/gtkdialog/pfselect

So, in any other script or app, we could call up a file selecter thingy, with only:

. /usr/lib/puppy/gtkdialog/pfselect
FILE=pfselect($WIDTH $HEIGHT $TITLE)
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#37 Post by technosaurus »

I was thinking about doing a rewrite so that more functions are split out into useful, generic functions. Zigbert did this to some extent, but I want to extend the traditional dialogs to actual "dialogs" (text2speech and voice recognition via espeak and pocket_sphinx_continuous) which is easier to do in a more structured approach. For example when a gtkdialog item list is generated, a corresponding voice menu is generated (if enabled) I'm considering extending the html generation with a httpd cgi backend as an alternative to gtkdialog (we could then use any browser for dialogs including netsurf-framebuffer/dillo or operate it headless/remotely).
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#38 Post by amigo »

Thanks for the 'lsof'. Too bad about the calls to readlink and sort. Of course the sort is probably not needed anyway. Can you think of how to implement readlink with only shell builtins?
As for the sort, I have a shell-only sort routine, or even better a uniq_no_sort routine. bash-only though as it uses arrays.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#39 Post by technosaurus »

@amigo - readlink can be ~like this:
http://stackoverflow.com/a/1116890/1162141
and a simple sort:
http://stackoverflow.com/a/16578322/1162141
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#40 Post by goingnuts »

sc0ttman: Fully support your thoughts. Might be difficult though - as we tend to focus on/understand best/use... our own X/no-X UIs. The X part explodes in favorite flavors - Xdialog, GTKdialog(1/2/3), yafsplash, xmessage etc. Need a very easy to use abstraction layer and/or a narrow selection of toolkits in use...

Post Reply