Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Bash: replace the former output with the new one
- kiyop
- Posts: 3983
- Joined: 2011-05-05 15:16
- Location: Where persons without desire to improve themselves fear to tread, in Japan
- Been thanked: 3 times
Re: Bash: replace the former output with the new one
I will check https://github.com/hakerdefo/pmrp
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
http://kiyoandkei.bbs.fc2.com/
- kiyop
- Posts: 3983
- Joined: 2011-05-05 15:16
- Location: Where persons without desire to improve themselves fear to tread, in Japan
- Been thanked: 3 times
Re: Bash: replace the former output with the new one
I read https://github.com/hakerdefo/pmrp/blob/master/pmrp
The above displays all the titles of the played radio stream including the old ones, doesn't it?
You may be able to shrink the script by using arrays. For example,
lines from #138 to #264 may be able to be replaced with the following:
You can also use "dialog" for selector.
You can install dialog by executing the following with root privilege:
And you can read manual of dialog:
The above displays all the titles of the played radio stream including the old ones, doesn't it?
You may be able to shrink the script by using arrays. For example,
lines from #138 to #264 may be able to be replaced with the following:
Code: Select all
function UrbaN_181fM (){
Name=("Jammin 181" "Old School HipHop" "The Beat" "The Box" "Trinity" "True R&B")
link=("http://relay.181.fm:8042" "http://relay.181.fm:8068" "http://relay.181.fm:8054" "http://relay.181.fm:8024" "http://icyrelay.181.fm/181-trinityhiphop_128k.mp3" "http://relay.181.fm:8022")
clear
echo -e "Stations Playing $BLUE Urban Music $NC :"
echo ""
for i in 1 2 3 4 5 6
do
echo -e "$BLUE 0$i $NC ${Name[$[i-1]]}"
done
echo -e "$RED 07 $BLUE Return to 181FM Menu $NC"
echo ""
echo -e "Select a $BLUE station $NC between 1 to 6 and hit $BLUE [Enter] $NC to $BLUE PLAY $NC :"
read PLAY
if test "$PLAY" -ge 1 -a "$PLAY" -le 6 2>/dev/null
then
clear
echo -e "$BLUE PMRP $NC -> $BLUE 181FM $NC -> $BLUE Urban $NC -> $BLUE ${Name[$[i-1]]} $NC:"
echo ""
echo -e "Press $BLUE [Space] $NC to pause : Press $BLUE [Q] $NC to stop"
echo ""
echo ""
echo -e "$BLUE Playlist $NC:"
echo ""
$PLAYER "${link[$[i-1]]}" 2>&1 /dev/null | grep --line-buffered "StreamTitle" | sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g"
UrbaN_181fM
elif [ "$PLAY" = 7 ]
then
clear
181fM
fi
clear
echo ""
echo -e "$RED $PLAY $NC $BLUE is an invalid selection! $NC"
echo ""
sleep 3
UrbaN_181fM
}
You can install dialog by executing the following with root privilege:
Code: Select all
apt-get install dialog
Code: Select all
man dialog
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
http://kiyoandkei.bbs.fc2.com/
Re: Bash: replace the former output with the new one
Yes, it does.kiyop wrote:I read https://github.com/hakerdefo/pmrp/blob/master/pmrp
The above displays all the titles of the played radio stream including the old ones, doesn't it?
And thanks for the great tip. That tip not only shrinks the script but makes it more readable and easier to understand.
Cheers!!!
-
- Posts: 41
- Joined: 2014-02-01 02:21
- Location: The Space Coast of the USA
Re: Bash: replace the former output with the new one
This works because xterm takes ANSI positioning codes.
See:
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
See:
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
Code: Select all
#!/bin/bash
x="Now is the time*for all good men*to come to the aid*of their country"
IFS="*"
X=($x)
clear
for ((k=0; k<4; k++)); do
echo ${X[k]}
sleep 1
done
echo
MoveUp=`echo -e "\033[1A"`
ClearLine=`echo -e "\033[K"`
echo "Press ENTER for the 2nd part"
read
echo
echo
for ((k=0; k<4; k++)); do
echo -n $MoveUp$ClearLine
echo ${X[k]}
sleep 1
done
- kiyop
- Posts: 3983
- Joined: 2011-05-05 15:16
- Location: Where persons without desire to improve themselves fear to tread, in Japan
- Been thanked: 3 times
Re: Bash: replace the former output with the new one
Thank you for telling ANSI positioning codes
The former script of mine which does not display unnecessary output can be shrink a little bit:
The former script of mine which does not display unnecessary output can be shrink a little bit:
Code: Select all
refreshsecond=1
ao=""
mpg123 http://streaming.radionomy.com/-1ClassicRock 2>&1 /dev/null | grep "StreamTitle" | cut -d \' -f2 > temporarylogfile &
pid=$!
echo -ne "\033[s"
while [ -n "$(ps a|grep "^ *$pid ")" ];do
a=$(tail -n1 temporarylogfile)
if [ ! "$a" = "$ao" ];then echo -ne "\033[u\033[K$a";ao=$a;fi
echo $a > temporarylogfile # can be omitted
sleep $refreshsecond
done
rm -r temporarylogfile
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
http://kiyoandkei.bbs.fc2.com/