Posted: Fri 29 Apr 2011, 13:54
I'd say that n1 could be the problem. I reckon -n 1 might work.Bruce B wrote:I think something didn't do right, so I decided to echo -nCode: Select all
read n1 a -p "Enter choice "
READ-ONLY Archive
https://oldforum.puppylinux.com/
I'd say that n1 could be the problem. I reckon -n 1 might work.Bruce B wrote:I think something didn't do right, so I decided to echo -nCode: Select all
read n1 a -p "Enter choice "
Shep,As a technique to be applied to other puppies, this will only work if you can
be sure the contents of file PUPSTATE will adhere to identical syntax for all
puplets. Can you be sure of this? Otherwise, a more robust algorithm will be
needed
Bruce B wrote:After about seven years working with Puppy, I can be confident in saying,
'Barry changes things.' I'm certain I don't know what he will do in the future.
I have further polished the code I suggested for setting pupdir & pupfile a few posts back. Scroll back to see. It's now down to one line, so I probably can't reduce it much further.It would also be a good exercise for this audience to test and rework existing code, as needed.
Code: Select all
0 #!/bin/bash
1
2 main() {
3
4 sanity $@
5 count_infile_lines $@
6 get_format $@
7 make_numbers
8 paste_files $@
9 exit 0
10
11 }
12
13 sanity() {
14
15 [ ! $1 ] && echo "Enter filename to number" && exit 1
16 [ ! -f $1 ] && echo "File $2 doesn't exist" && exit 1
17
18 }
19
20 count_infile_lines() {
21
22 lines=`grep -c ^ $1`
23
24 }
25
26 get_format() {
27
28 if [ "$lines" -le "9" ] ; then
29 format=1
30 elif [ "$lines" -le "99" ] ; then
31 format=2
32 elif [ "$lines" -le "999" ] ; then
33 format=3
34 else
35 echo "Error, exiting"
36 exit 1
37 fi
38
39 }
40
41 make_numbers() {
42
43 [ -f /tmp/${script}.tmp ] && rm /tmp/${script}.tmp
44
45 for ((i;i<=${lines};i++)) ; do
46 printf "%${format}d \n" $i >> /tmp/${script}.tmp
47 done
48
49 }
50
51 paste_files() {
52
53 paste /tmp/${script}.tmp $1 > $1.nbr
54 echo "Numbered file saved as \"$1.nbr\""
55
56 }
57
58 script=`basename $0`
59 main $@
60
Code: Select all
make_colors() {
mag() {
echo -en "\033[35;1m"
}
cya() {
echo -en "\033[36;1m"
}
}
Code: Select all
mag=`echo -en "\033[35;1m"`
cya=`echo -en "\033[36;1m"`
Code: Select all
0 13) #PDEV1 and PUPSFS and PUPSAVE
1 #/initrd/pup_rw has tmpfs, pup_ro1 has ${DISTRO_FILE_PREFIX}save.2fs file {cut out}
2 #the above are in unionfs at /.
3 echo "Saving session to $SAVEFILE (${SAVEPART})..." >/dev/console
4 /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
5 ;;
Code: Select all
0 13) #PDEV1 and PUPSFS and PUPSAVE
1 #/initrd/pup_rw has tmpfs, pup_ro1 has ${DISTRO_FILE_PREFIX}save.2fs {cut out}
2 #the above are in unionfs at /.
3 echo -n "Save this session (y,n) ? " >/dev/console
4 read ans
5 if [ "$ans" = "y" ] ; then
6
7 echo "Saving session to $SAVEFILE (${SAVEPART})..." >/dev/console
8 /usr/sbin/snapmergepuppy /initrd/pup_ro1 /initrd/pup_rw
9
10 fi
11 ;;
Code: Select all
urxvt*title:Bash
urxvt*geometry:80x25+224+345
urxvt*pointerBlankDelay:5
urxvt*iconName:urxvt
urxvt*externalBorder:2
urxvt*font:7x14B
urxvt*background:black
urxvt*foreground:white
urxvt*scrollWithBuffer:true
urxvt*pastableTabs:false
urxvt*saveLines:9000
urxvt*scrollBar:false
urxvt*cursorColor:grey50
rxvt*title:Bash
rxvt*geometry:80x25+224+345
rxvt*pointerBlankDelay:5
rxvt*iconName:rxvt
rxvt*externalBorder:2
rxvt*font:7x14B
rxvt*background:black
rxvt*foreground:white
rxvt*scrollWithBuffer:true
rxvt*pastableTabs:false
rxvt*saveLines:9000
rxvt*scrollBar:false
rxvt*cursorColor:grey50
Code: Select all
termName: string
geometry: geometry
chdir: string
reverseVideo: boolean
loginShell: boolean
jumpScroll: boolean
skipScroll: boolean
pastableTabs: boolean
scrollstyle: mode
scrollBar: boolean
scrollBar_right: boolean
scrollBar_floating: boolean
scrollBar_align: mode
thickness: number
scrollTtyOutput: boolean
scrollTtyKeypress: boolean
scrollWithBuffer: boolean
inheritPixmap: boolean
transparent: boolean
tintColor: color
shading: number
utmpInhibit: boolean
urgentOnBell: boolean
visualBell: boolean
mapAlert: boolean
meta8: boolean
mouseWheelScrollPage: boolean
tripleclickwords: boolean
insecure: boolean
cursorUnderline: boolean
cursorBlink: boolean
pointerBlank: boolean
background: color
foreground: color
color0: color
color1: color
color2: color
color3: color
color4: color
color5: color
color6: color
color7: color
color8: color
color9: color
color10: color
color11: color
color12: color
color13: color
color14: color
color15: color
colorBD: color
colorIT: color
colorUL: color
colorRV: color
underlineColor: color
scrollColor: color
troughColor: color
highlightColor: color
cursorColor: color
cursorColor2: color
pointerColor: color
pointerColor2: color
borderColor: color
font: fontname
boldFont: fontname
italicFont: fontname
boldItalicFont: fontname
intensityStyles: boolean
inputMethod: name
preeditType: style
imLocale: string
imFont: fontname
title: string
iconName: string
saveLines: number
depth: number
buffered: boolean
transient-for: windowid
override-redirect: boolean
hold: boolean
externalBorder: number
internalBorder: number
borderLess: boolean
lineSpace: number
skipBuiltinGlyphs: boolean
pointerBlankDelay: number
backspacekey: string
deletekey: string
print-pipe: string
modifier: modifier
cutchars: string
answerbackString: string
secondaryScreen: boolean
secondaryScroll: boolean
keysym.sym: keysym
Code: Select all
#!/bin/bash
xrdb -merge -nocpp /root/.Xresources
Code: Select all
#!/bin/bash
printf '\33]2;%s\007' `pwd`
Code: Select all
#!/bin/bash
printf '\33]2;%s\007' "$1"
Code: Select all
Archive: urxvt-title-tools.zip
Length Date Time Name
--------- ---------- ----- ----
40 2011-05-06 03:14 utitle
41 2011-05-06 18:35 cdir
--------- -------
81 2 files
Code: Select all
#/bin/bash
mp3blaster --option --option --option --option *.mp3
# Mp3blaster v3.2.4 (C)1997 - 2009 Bram Avontuur.
# Usage:
# mp3blaster [options]
# mp3blaster [options] [file1 ...]
# Play one or more mp3's
# mp3blaster [options] --list/-l <playlist.lst>
# Load a playlist but don't start playing.
# mp3blaster [options] --autolist/-a <playlist.lst>
# Load a playlist and start playing.
#
# Options:
# --downsample/-2: Downsample (44->22Khz etc)
# --8bits/-8: 8bit audio (autodetected)
# --config-file/-c=file: Use other config file than the default
# ~/.mp3blasterrc
# --debug/-d: Log debug-info in $HOME/.mp3blaster.
# --status-file/-f=file: Keep info on the mp3s being played, in the
# specified file.
# --help/-h: This help screen.
# --mixer-device/-m: Mixer device to use (use 'NAS' for NAS mixer)
# --no-mixer/-n: Don't start the built-in mixer.
# --chroot/-o=<rootdir>: Set <rootdir> as mp3blaster's root dir.
# This affects *ALL* file operations in mp3blaster!!(including
# playlist reading&writing!) Note that only users with uid 0
# can use this option (yet?). This feature will change soon.
# --playmode/-p={onegroup,allgroups,allrandom}
# Default playing mode is resp. Play first group only, Play
# all groups, Play all songs in random order.
# --dont-quit/-q: Don't quit after playing mp3[s] (only makes sense
# in combination with --autolist or files from command-line)
# --repeat/-R: Repeat playlist.
# --runframes/-r=<number>: Number of frames to decode in one loop.
# Range: 1 to 10 (default=5). A low value means that the
# interface (while playing) reacts faster but slow CPU's might
# hick. A higher number implies a slow interface but less
# hicks on slow CPU's.
# --sound-device/-s=<device>: Device to use to output sound.
# Default for your system is /dev/dsp.
# If you want to use NAS (Network Audio System) as playback
# device, then enter the nasserver's address as device (e.g.
# host.name.com:0; it *must* contain a colon)
# --threads/-t=<amount>: Numbers of threads to use for buffering
# (only works if mp3blaster was compiled with threads). Range is
# 0..500 in increments of 50 only.
# --version,v: Display version number.
Code: Select all
sed 's/^/# /'
Code: Select all
0 #!/bin/bash
1
2 main() {
3
4 variables
5 sanity "$@"
6 searchfile "$@"
7 exit 0
8
9 }
10
11 variables() {
12
13 directory=/var/repos
14 file=debian-ls-lR.gz
15 tmpdir=/tmp
16 tmpfile=debian.txt
17
18 }
19
20 sanity() {
21
22 [ ! -f $directory/$file ] \
23 && echo -n "Required file: " \
24 && echo -n "$directory/$file doesn't" \
25 && echo " exist, exiting . . ." && exit
26
27 if [ ! $1 ] ; then
28 echo -n "You need to enter a search criteria"
29 echo " for archive \"$file\""
30 fi
31
32 }
33
34 searchfile() {
35
36 [ -f $tmpdir/$tmpfile ] && rm $tmpdir/$tmpfile
37 <$directory/$file zcat | grep -i "$@" > $tmpdir/$tmpfile
38
39 if [ -s $tmpdir/$tmpfile ] ; then
40
41 cat $tmpdir/$tmpfile
42
43 read -p "Save search results (y,n) ? " -n 1 ans
44
45 # note moving to other function depending on answer
46
47 [ "$ans" = "y" ] && saveresults "$@" || echo
48
49 else
50
51 echo No results for "$@"
52
53 fi
54
55 [ -f $tmpdir/$tmpfile ] && rm $tmpdir/$tmpfile
56
57 }
58
59 saveresults() {
60
61 # called from searchfile
62
63 echo
64
65 read -p "Please enter filename prefix: " name
66
67 mv $tmpdir/$tmpfile $directory/$name-$tmpfile
68
69 echo "Results saved as: $directory/$name-$tmpfile"
70
71 }
72
73 main "$@"
74
I rarely use ls for file operations anymore, just string manipulation and filetype checks with recursion as necessaryausvirgo wrote:presumably the "ls" is the problem.
Code: Select all
[ $1 ] && [ -d $1 ] && cd $1
for x in * ; do
y=${x// /_}
[ "$x" != "$y" ] && mv "${x}" "${y}"
[ -d $y ] && $0 $y &
done
The example you posted which I bolded is the way I would do it.ausvirgo wrote:for i in `ls *.deb`; do undeb $i; shift; done
doesn't work on my puppy (Yes, I know I'm not in 4.21).
for i in *.deb; do undeb $i; done
works (quotes around "*.deb" seem to be optional).
It may be.ausvirgo wrote: for i in `ls *.deb`; do echo $i; shift; done
returns "ls zynaddsubfx_2.2.1-2.1_i386.deb" instead of
"zynaddsubfx_2.2.1-2.1_i386.deb"
presumably the "ls" is the problem.
It is not my post to edit. And it isn't my topic. I simply make a lot ofausvirgo wrote:You might want to edit the original post, as this is
a stumbling block in following your tutorial.
I'll try to provide more feedback as I go through the tutorial.
A simple version of the rule:works (quotes around "*.deb" seem to be optional).
Code: Select all
for i in *.deb; do
undeb $i
done
Code: Select all
for x in * ; do
y=${x// /_}
for small substitutions it is quick and doesn't require sed or tr, but works in ash and other small posix compliant shells. (the strings can be multiple character too, making it a good little trick to use in init scripts)jpeps wrote:I did like the cute substitution example though
Code: Select all
for x in * ; do y=${x// /_}