My scripts
Description:
Bash
A Multi-Line Technical Script Below:
Company |
Alfreds Futterkiste |
Centro comercial Moctezuma |
Pause in loops:
#!/bin/bash
#YES while read line
#Count 5 lines then pause
cont=0
while read line
do if [ $cont -eq 5 ]
then read -p "Press Enter to continue..." < /dev/tty #YES ADD THIS LINE
cont=0
fi
printf '%s\n' "$line"
cont=$((cont + 1))
done < seahist.txt
#!/bin/bash
#YES while read line
cont=0
while read line <&3
do
if [ $cont -eq 5 ]
then read -p "Press Enter to continue..."
cont=0
fi
printf '%s\n' "$line"
cont=$((cont + 1))
done 3< seahist.txt
#!/bin/bash
#YES while true
#Pause and continue
echo 'Press "s" to pause loop or Ctrl+c to stop' #THIS
n=1
while true; do
#THIS
read -r -t 0.5 -n 1 -s stop
[ -n "${stop}" ] && {
read -p 'Paused... press Enter button for continue' x
}
#TO THIS
n=$(( n+=1 ))
echo "Loop Counter: ${n}"
done
#!/bin/bash
#YES while true
echo 'Press "enter" to continue loop or Ctrl+c to stop'
n=1
while true; do
read -n 1 -p Continue?
n=$(( n+=1 ))
echo "Loop Counter: ${n}"
done
Backlightadj:
#/bin/sh
# by stemsee
#BRAND=$(ls /sys/class/backlight/ | grep _backlight)
#radeon_bl0
BRAND=$(ls /sys/class/backlight/)
yad --title="Screen Brightness" --height=40 --width=400 \
--no-buttons --on-top --hori --scale \
--print-partial --min-value=0 --max-value=$(cat /sys/class/backlight/$BRAND/max_brightness) --step=1 --value=$(cat /sys/class/backlight/$BRAND/brightness) | while read line; do echo "$line" > /sys/class/backlight/$BRAND/brightness; sleep 0.01; done
echo "$(cat /sys/class/backlight/$BRAND/brightness)"
#echo "$(cat /sys/class/backlight/$BRAND/brightness)" &
screamerfavtoall:
screamerfavtoall: precode https://www.browserling.com/tools/html-encode
#!/bin/bash
#get urls list for puppy from screamer favorites (url)
# <Station title="Classic Hits Forest Gold" url="http://www.radioforest.co.uk">
# <Source>http://78.129.232.15:8000/stream</Source>
# </Station>
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to =" #add URL to start
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/^/=/' | sed 's/$/"/' | grep -n '^' | sed 's/:=/="/g' | sed 's/^/URL/' > urls
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #add = to start #grep number lines #change := to = #add CH to start
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/^/=/' | grep -n '^' | sed 's/:=/=/g' | sed 's/^/CH/' > stations
echo
echo "Stations and URLs Done." #ph
echo "wait 10s to continue building m3u files, or press any key to exit." #ph
read -n 1 -t 10
#This will wait 10 seconds for single char. If key was pressed return value will be 0:
if [ $? == 0 ]; then
# key was pressed
exit
fi
echo "Building m3u..."
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to ="
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g' > urls.m3u
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #remove last char #remove first char
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/.$//g' | sed 's/^.//' | sed 's/^/#EXTINF:0,/' > stationsvlc
#merge stationsvlc and urls.m3u
echo "#EXTM3U" > radiovlc.m3u
paste -d '\n' stationsvlc urls.m3u >> radiovlc.m3u
echo
echo "m3u Done." #ph
echo "wait 10s to continue making radio.htm, or press any key to exit." #ph
read -n 1 -t 10
#This will wait 10 seconds for single char. If key was pressed return value will be 0:
if [ $? == 0 ]; then
# key was pressed
exit
fi
echo "making radio.htm..."
#check if radio.htm exists and delete
echo "delete radio.htm NOW before continuing"
read -p "Press [Enter] key to continue..."
echo "<html><head><title>radio generated from favorites</title></head><body>" >> radio.htm
echo "<h1 align="center">Radio Page</h1>" >> radio.htm
echo "<table border="1" align="center" height="360" width="720" bgcolor="#E7E9FB" cellpadding="0" cellspacing="1"><tr>" >> radio.htm
#If you don't like the to put < file at the end, you can also pipe the contents of the file to the while loop:
unumber=0
while read line;
do
if echo "$line" | grep -q "Source"
then
echo "Sourceok"
# url="$(echo $line | grep Source | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g')"
url="$(echo $line | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g')"
echo $url
fi
if echo "$line" | grep -q "title"
then
echo "titleok"
station="$(echo $line | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/.$//g' | sed 's/^.//')"
echo $station
fi
if echo "$line" | grep -q "/Station"
then
echo "/Stationok"
echo "<td valign="middle" align="center" bgcolor="#E7E9FB" width="150" height="70">" >> radio.htm
echo "<a href='$url' TARGET="_blank"><img src='rbut0037.gif' BORDER=0 alt='$station'><br />$station</a></td>" >> radio.htm
if [ $unumber = "3" ]
then
echo "three"
echo "</tr><tr>" >> radio.htm
unumber=0
echo "$unumber"
else
unumber=$((unumber+1))
echo "$unumber"
fi
fi
done < favorites.xml
echo "</tr></table>" >> radio.htm
echo "</body></html>" >> radio.htm
screamerfavtoall: precodetable https://www.browserling.com/tools/html-encode
#!/bin/bash
#get urls list for puppy from screamer favorites (url)
# <Station title="Classic Hits Forest Gold" url="http://www.radioforest.co.uk">
# <Source>http://78.129.232.15:8000/stream</Source>
# </Station>
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to =" #add URL to start
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/^/=/' | sed 's/$/"/' | grep -n '^' | sed 's/:=/="/g' | sed 's/^/URL/' > urls
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #add = to start #grep number lines #change := to = #add CH to start
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/^/=/' | grep -n '^' | sed 's/:=/=/g' | sed 's/^/CH/' > stations
echo
echo "Stations and URLs Done." #ph
echo "wait 10s to continue building m3u files, or press any key to exit." #ph
read -n 1 -t 10
#This will wait 10 seconds for single char. If key was pressed return value will be 0:
if [ $? == 0 ]; then
# key was pressed
exit
fi
echo "Building m3u..."
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to ="
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g' > urls.m3u
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #remove last char #remove first char
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/.$//g' | sed 's/^.//' | sed 's/^/#EXTINF:0,/' > stationsvlc
#merge stationsvlc and urls.m3u
echo "#EXTM3U" > radiovlc.m3u
paste -d '\n' stationsvlc urls.m3u >> radiovlc.m3u
echo
echo "m3u Done." #ph
echo "wait 10s to continue making radio.htm, or press any key to exit." #ph
read -n 1 -t 10
#This will wait 10 seconds for single char. If key was pressed return value will be 0:
if [ $? == 0 ]; then
# key was pressed
exit
fi
echo "making radio.htm..."
#check if radio.htm exists and delete
echo "delete radio.htm NOW before continuing"
read -p "Press [Enter] key to continue..."
echo "<html><head><title>radio generated from favorites</title></head><body>" >> radio.htm
echo "<h1 align="center">Radio Page</h1>" >> radio.htm
echo "<table border="1" align="center" height="360" width="720" bgcolor="#E7E9FB" cellpadding="0" cellspacing="1"><tr>" >> radio.htm
#If you don't like the to put < file at the end, you can also pipe the contents of the file to the while loop:
unumber=0
while read line;
do
if echo "$line" | grep -q "Source"
then
echo "Sourceok"
# url="$(echo $line | grep Source | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g')"
url="$(echo $line | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g')"
echo $url
fi
if echo "$line" | grep -q "title"
then
echo "titleok"
station="$(echo $line | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/.$//g' | sed 's/^.//')"
echo $station
fi
if echo "$line" | grep -q "/Station"
then
echo "/Stationok"
echo "<td valign="middle" align="center" bgcolor="#E7E9FB" width="150" height="70">" >> radio.htm
echo "<a href='$url' TARGET="_blank"><img src='rbut0037.gif' BORDER=0 alt='$station'><br />$station</a></td>" >> radio.htm
if [ $unumber = "3" ]
then
echo "three"
echo "</tr><tr>" >> radio.htm
unumber=0
echo "$unumber"
else
unumber=$((unumber+1))
echo "$unumber"
fi
fi
done < favorites.xml
echo "</tr></table>" >> radio.htm
echo "</body></html>" >> radio.htm
|
what is this for text=#000000 vLink=#000000 aLink=#d7d7d7 link=#969696 bgColor=#f9f9f9
screamto3.sh
Code: |
#!/bin/bash
#get urls list for puppy from screamer favorites (url)
# <Station title="Classic Hits Forest Gold" url="http://www.radioforest.co.uk">
# <Source>http://78.129.232.15:8000/stream</Source>
# </Station>
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to =" #add URL to start
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/^/=/' | sed 's/$/"/' | grep -n '^' | sed 's/:=/="/g' | sed 's/^/URL/' > urls
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #add = to start #grep number lines #change := to = #add CH to start
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/^/=/' | grep -n '^' | sed 's/:=/=/g' | sed 's/^/CH/' > stations
echo
echo "Stations and URLs Done." #ph
echo "wait 10s to continue building m3u file, or press any key to exit." #ph
read -n 1 -t 10
#This will wait 5 seconds for single char. If key was pressed return value will be 0:
if [ $? == 0 ]; then
# key was pressed
exit
fi
echo "Building m3u..."
#grep lines with Source#rest of line after source#remove last 8 chars#add = to start#add " to end#grep number lines #change := to ="
grep Source ./favorites.xml | sed 's/^.*<Source>//' | sed 's/..........$//g' | sed 's/:=/="/g' > urls.m3u
#grep lines with title #rest of line after title= #display line before other = #remove last 4 chars #remove last char #remove first char
grep title ./favorites.xml | sed 's/^.*title=//' | sed 's/=.*//' | sed 's/....$//g' | sed 's/.$//g' | sed 's/^.//' | sed 's/^/#EXTINF:0,/' > stationsvlc
#merge stationsvlc and urls.m3u
echo "#EXTM3U" > radiovlc.m3u
paste -d '\n' stationsvlc urls.m3u >> radiovlc.m3u
|