Sunday, May 15, 2011

Nuevos programillas BASH de este finde

Primera firma de evolution:
#!/bin/bash
echo "<div>-- </div>"
echo "<p>Estoy usando: "
# cat /etc/lsb-release
# uname -s -n -r -v -m -o
# saca los 4 ultimos programas abiertos por su nombre
xlsclients | tail -4 | awk '{print $2}'
echo " entre otros programas mientras envio esto"
echo "</p>"
Segunda firma:
#!/bin/bash
echo "<div>-- </div>"
echo "<p>Mi ordenador es: "
# cat /etc/lsb-release
uname -s -n -r -v -m -o
echo "</p>"
Y un algo para leer identi.ca y publicar identica. Lo guai de este es que no lee lo publico sino solo tuyo y de tus amigos.
#!/bin/bash
# Based in part on article found at http://www.ibm.com/developerworks/linux/library/l-friendfeed/index.html
# Obtainded from http://lincgeek.org/linc/scripts/identibash
# Added GUI from Linux Format issue 144
maxitems=5
dent0=gato
dent1=perro
dent2=hormiga
dent3=chorizo
dent4=paella
# user=yourusername
# pass=secretpassword
# puburl="http://stream.tllts.org/identica/api/statuses/public_timeline.xml"
#http://identi.ca/ubuntuast
#/api/statusnet/groups/timeline.format
puburl="http://identi.ca/api/statuses/public_timeline.xml"
usrurl="http://identi.ca//api/statuses/friends_timeline.xml"
# /api/statuses/friends_timeline.xml
#puburl="http://identi.ca/api/statuses/show/73223477.xml"
posturl="http://identi.ca/api/statuses/update.xml?source=AndresBash!"
# echo "what is your username"
user=$(zenity --entry --text "escribe nombre usuario")
# read user

# echo "what is your password"
pass=$(zenity --entry --text "escribe clave")
# read pass
# echo "write a message"
# read mens
# curl -s -u ${user}:${pass} -d status="${mens}" ${posturl}

function readpub()
{
clear
curl -u ${user}:${pass} $usrurl >/tmp/tweet.tmp
# http://identi.ca/api/statuses/friends_timeline.xml
# curl $puburl > /tmp/tweet.tmp
count=0
echo "-------------------------------------------"
while read line
do
if $(echo "${line}" | grep -q "text>")
then
echo "${line}" | sed 's/<text>//g' | sed 's/<\/text>//g'
notify-send -t 1000 "${line}" -i /home/andres/Documents/programillas/andres-icon.png
# dent$((count))="${line}"
fi


if $(echo "${line}" | grep -q "created_at>")
then
echo -n "${line}" | sed 's/<created_at>/  @: /g' | sed 's/<\/created_at>//g'
fi




if $(echo "${line}" | grep -q "in_reply_to_screen_name>")
    then
echo "${line}" | sed 's/<in_reply_to_screen_name>/ replying: /g' | sed 's/<\/in_reply_to_screen_name>//g'
fi

if $(echo "${line}" | grep -q "screen_name>")
then
echo "${line}" | sed 's/<screen_name>/ by: /g' | sed 's/<\/screen_name>//g'
fi

if $(echo "${line}" | grep -q "</status>")
then
echo "-------------------------------------------"
count=$((count + 1))
if [ $count -eq $maxitems ]
then
break
fi
fi
# echo $dent0
done < /tmp/tweet.tmp
}

function postmsg()
{
curl -s -u ${user}:${pass} -d status="$msg" ${posturl} 2>&1>/dev/null

}
# function user()
# {
# curl -s -u ${user}:${pass} -d status="$msg" ${usrurl}
# }

getopts "rp:" flag
case "${flag}" in
# this means that after the instruction you add -r to read (-r is a flag)
r) readpub ;;
# this needs -p plus a post meassage. It will also do the reading.
# so it looks like this identibash -p "my message to dent"

# p) msg=${OPTARG}; postmsg; readpub ;;
p) msg=${OPTARG}; postmsg; readpub ;;
# u) s=${s};;
esac

perdonad por los comentarios.
-- Mi ordenador es: Linux andres-laptop 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:24:35 UTC 2011 i686 GNU/Linux