Regole del forum
1) Citare in modo preciso il nome del pacchetto.
2) Specificare se discussione/suggerimento o richiesta d'aiuto.
3) Leggere attentamente le risposte ricevute
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.
La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.
Salve ragazzi ieri mi so messo in testa di fare uno script che mi facilitasse la ricerca sul package browser di slackware. Ebbene si'! l'ho finito adesso e però mi sembra che il codice sia un pò sporco. Mi date una mano a pulirlo un pò? :P
#!/bin/sh
##########################################################################
# #
# Copyright (C) 2005-2006 - SlackPB v1.0 by Fr4NkiR #
# #
# Author: Francesco 'Fr4NkiR' Pasqua <frankir@gmail.com> #
# #
# Thanks: #
# - Fulvio 'VuLfiO' Becherucci for english translation #
# <blue69shark89@yahoo.it> #
# #
# Slackpb is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# Slackpb is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
# #
##########################################################################
ver=1.0
file=/tmp/slackpb.tmp
conn=`/sbin/ifconfig ppp0 &> /dev/null`
#Testing Internet Connection
if [ "$conn" == "" ];
then
echo -e "\nWarning: ppp0 is down - Are you connected on internet?!\n"
exit 0
fi
help()
{
echo "slackpp by Fr4NkiR
Usage: slackpb --ACTION WORD OPTION
--slack WORD < -c|-10.2|-10.1|-10.0|-9.1|-9.0|-8.1 >
--patches WORD < -c|-10.2|-10.1|-10.0|-9.1|-9.0|-8.1 >
--extra WORD < -c|-10.2|-10.1|-10.0|-9.1|-9.0|-8.1 >
--help View this message
--version View slackpb version
Example: slackpb --slack libFLAC.so -c"
}
slack_ver()
{
if [ $sv != "-10.2" ] && [ $sv != "-10.1" ] && [ $sv != "-10.0" ] && [ $sv != "-9.1" ] && [ $sv != "-9.0" ] && [ $sv != "-8.1" ];
then
opt="current"
else
opt=`echo $sv | cut -d"-" -f2`
fi
}
alg()
{
url="http://www.slackware.it/pb/searchfile.php?v=$opt&c=$category&string=$word&w=on"
/usr/bin/lynx -dump -accept_all_cookies $url > $file
start=`cat -n /tmp/slackpb.tmp | grep "Showing" | awk -F " " '{printf $1" "}' | awk -F" " '{print $1}'`
end=`cat -n /tmp/slackpb.tmp | grep "Showing" | awk -F " " '{printf $1" "}' | awk -F" " '{print $2}'`
tot_line=`expr $end - $start`
head -n $end $file &> /tmp/pb
tail -n $tot_line /tmp/pb &> $file
cat $file | grep 486 | awk -F" " '{print $1}' | awk -F"]" '{print $2}'
cat $file | grep 386 | awk -F" " '{print $1}' | awk -F"]" '{print $2}'
cat $file | grep 686 | awk -F" " '{print $1}' | awk -F"]" '{print $2}'
rm -rf $file && rm -rf /tmp/pb
}
not_par()
{
if [ "$word" == "" ];
then
echo -e "\nError:\tParameters insufficient: you haven't insert the WORD.\n\tPlease type 'slackpb --help' for more informations!\n"
exit 1
fi
}
if [ "$3" == "" ];
then sv="current"
else sv=$3
fi
case $1 in
"--slack")
word=$2; not_par; category="slackware"
slack_ver && alg
exit 0
;;
"--patches")
word=$2; not_par; category="slackware"
slack_ver && alg
exit 0
;;
"--extra")
word=$2; not_par; category="slackware"
slack_ver && alg
exit 0
;;
"--help")
help
exit 0
;;
"--version")
echo "slackpb $ver"
exit 0
;;
*)
help
exit 0
;;
esac
a me sembra molto carino, l'unica è che farei scegliere (o userei una variabile distinta) per identificare l'interfaccia di connessione. io, ad esempio, uso eth0 e non ppp0. bel lavoro comunque
Oddio, difficilemente riesco a mettere mani su codice non mio, comunque va bene...
Dovresti cambiare il controllo della connessione peró, molti stanno dietro ad un router, non è detto che abbiano un'interfaccia ppp0.
Ad esempio puoi pingare verso l'esterno, che ne so..
FrANkiR ha scritto:Lorys vorrei tiggizzarlo...ma non so come...vorrei fare che si posiziona dentro una di quste directory: /usr/local/bin o /bin o /usr/bin
Non ci pensare, mandami lo script e relativa documentazione, poi lo faccio io tgz.
"Ho una testa piuttosto balzana e comunque non sono quello che credete" - Roger Keith Barrett
Lorys ti ho inviato il programma via email, però sto notando che ho sbagliato la variabile $category inizializzata sempre al valore "slackware" e invece deve cambiare...poi sto modificando gli argv ... non metterlo per adesso...stasera te lo mando completo!!!
OOPS!! Lorys se puoi, prima di pacchetizzare, scommenta la riga che rimuove i file temporanei (nella funzione alg())!! grazie ma me l'ero dimenticato! :P