![Wink :wink:](./images/smilies/icon_wink.gif)
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
That's how the script was originally (from Saluki I think), if I remove "grep -v '\.'", it flashes 47% after it reaches 100. Can't get a working progress bar from your awk line.misko_2083 wrote:^this part has so many pipes.Code: Select all
script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | while read -n 99 LINE ; do PROG=`echo $LINE | egrep '[0-9]\%' | cut -f1 -d% | awk '{print $NF}'| grep -v '\.'` echo "#$PROG%" echo $PROG done | yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \ --text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
Not sure what is invert match at the end grep -v '\.' doing.
Awk can do all of that.Code: Select all
script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' | yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \ --text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
Oh I see it must work without terminal.That's how the script was originally (from Saluki I think), if I remove "grep -v '\.'", it flashes 47% after it reaches 100. Can't get a working progress bar from your awk line.
Code: Select all
script --return --flush --quiet --command \
"stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" |
awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' |
yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \
--text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
Code: Select all
file ..., uncompressed size 2755336 bytes
[=========\ ] 481/12359
3%
file ..., uncompressed size 726904 bytes
[==========\ ] 528/12359
4%
file ..., uncompressed size 577 bytes
[==============\ ] 719/12359
5%
Tried that, but no progress is showing for me.misko_2083 wrote:If I add flush to the script this is working for me:
Code:
script --return --flush --quiet --command \
"stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" |
awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' |
yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \
--text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
Code: Select all
echo $LINE | busybox strings |egrep '[0-9]\%' | cut -f1 -d% |awk '{print $NF}'|grep -v '\.'
Code: Select all
10%
10%
10%
14%
16%
18%
19%
20%
33%
51%
78%
100%
100%
100%
100%
100%
100%
100%
Kbytes)
bytes)
bytes)
Code: Select all
#!/bin/bash
t=`echo "$1" | sed "s/\/$//"`
z=`echo "$1" | sed "s/\/$//"`
[ ! -d "$t" ] && exit
if [ -f "$z.sfs" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $z).sfs</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -f "$z.sfs" "$z.sfs-md5.txt" ;;
*) exit ;;
esac
fi
yad --window-icon="application-x-squashfs-image" --title "Choose Compression Type" --text "Choose which algorthim to compress the sfs with.
Choosing XZ will give you a smaller sfs but may
be slower than GZIP on very lowspec machines.
XZ-HC is a higher compression XZ squashfile." --text-align="center" --borders="5" --buttons-layout="center" \
--button="GZIP:0" --button="XZ:1" --button="XZ-HC:2"
case $? in
0) COMP="-comp gzip" ;;
1) COMP="-comp xz" ;;
2) COMP="-comp xz -b 1024k -Xbcj x86" ;;
*) exit ;;
esac
(script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | while read -n 99 LINE ; do
echo $LINE | strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Building Squashfile " --gauge "Building $(basename $z).sfs\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall mksquashfs
rm -f typescript
exit
fi
rm -f typescript
md5sum "$z.sfs" > "$z.sfs-md5.txt"
sync
OK, will change to busybox strings. I had to get script from slackware util-linux pkg as it's not included in slacko.fredx181 wrote:.I'd say that "busybox strings" would be better because not every distro has "strings"
(btw, that might go for "script" also, anyway for info: it's part of package "bsdutils" in Ubuntu and Debian)
Fred
Code: Select all
#!/bin/bash
[ ! -d "$1" ] && exit
if [ "$(echo "$1" | wc -w)" -gt 1 ]; then
yad --window-icon="application-x-squashfs-image" --title="Rename Folder" --text="Remove blank spaces from\n<b>$(basename "$1")</b> \
and try again." --text-align="center" --borders="10" --width="220" --no-buttons --timeout="3"
exit
fi
if [ -f "$1.sfs" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $1).sfs</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -f "$1.sfs" "$1.sfs-md5.txt" ;;
*) exit ;;
esac
fi
yad --window-icon="application-x-squashfs-image" --title "Choose Compression Type" \
--text="XZ will give you a smaller sfs but may
be slower than GZIP on older machines.
XZ-HC is a higher compression XZ sfs." --text-align="center" --borders="10" --buttons-layout="center" \
--button="GZIP:0" --button="XZ:1" --button="XZ-HC:2"
case $? in
0) COMP="-comp gzip" ;;
1) COMP="-comp xz" ;;
2) COMP="-comp xz -b 1024k -Xbcj x86" ;;
*) exit ;;
esac
(script -q -c "stty rows 40 cols 100; mksquashfs "$1" "$1.sfs" $COMP" | while read -n 50 LINE ; do
echo $LINE | busybox strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Building Squashfile " --gauge "Building $(basename $1).sfs\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall mksquashfs
rm -f typescript
exit
fi
rm -f typescript
md5sum "$1.sfs" > "$1.sfs-md5.txt"
sync
rg66 wrote:Definitely my last one. Reverting back to "read -n 50 LINE" captures a lot more lines.
Edit: I've added a pop-up warning for folders with white spaces just in case.
Code: Select all
This also works for unsquashfs as well Very Happy
Sorry belham2, I meant the code will also work with the unsquashfs command.belham2 wrote:I just have one question: you wrote this above in an earlier message:
Am I misunderstanding? I dropped one of the newly created .sfs files on the script to test the unsquashfs capabilitiy, and the script does nothing.Code: Select all
This also works for unsquashfs as well Very Happy
Was/Is the script meant to do unsquashing too just by dropping a .sfs on it? (I don't see unsquashfs commands in the script, so was trying to figure out what you meant when you wrote "this also works for unsquashfs as well...very happy".
P.S. Just found something weird...in Micko's latest Slacko64 (700-r3), on another machine at my desk here, the script does nothing. It won't launch at all, even though it is set up the same way with the same permissions as in X-Slacko-4.4. Weird, as it should easily run in 64-bit slacko because it's only a script after all, right?
Code: Select all
#!/bin/bash
[ ! -f "$1" ] && exit
DIR="${1%.*}"
if [ "$(echo "$1" | wc -w)" -gt 1 ]; then
yad --window-icon="application-x-squashfs-image" --title="Rename File" --text="Remove blank spaces from\n<b>$(basename "$1")</b> \
and try again." --text-align="center" --borders="10" --width="220" --no-buttons --timeout="3"
exit
fi
if [ -d "$DIR" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $DIR)</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -rf "$DIR" ;;
*) exit ;;
esac
fi
(script -q -c "stty rows 40 cols 100; unsquashfs -d "$DIR" "$1"" | while read -n 50 LINE ; do
echo $LINE | busybox strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Extracting Squashfile " --gauge "Extracting $(basename $1)\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall unsquashfs
rm -f typescript
exit
fi
rm -f typescript
sync
Really!"As I see you guys go,
My love for console grows."