Xhack

Un forum dedicato all'hacking
 
IndiceIndice  PortalePortale  CalendarioCalendario  FAQFAQ  CercaCerca  RegistrareRegistrare  Lista utentiLista utenti  GruppiGruppi  Connessione  

Condividere | 
 

 Input in Bash

Vedere l'argomento precedente Vedere l'argomento seguente Andare in basso 
AutoreMessaggio
black hole
membro
membro


Numero di messaggi: 90
Data d'iscrizione: 03.10.07

MessaggioOggetto: Input in Bash   Gio Dic 27, 2007 1:57 pm

Come faccio a mettere un input in bash?
Se io ad esempio volessi fare uno script che cerca usando firefox dei video in tre siti diversi...come questo
Codice:
#!/bin/bash
REPLY=input
firefox http://www.metacafe.com/tags/$REPLY
firefox http://www.youtube.com/results?search_query=$REPLY&search=Search
firefox http://video.yahoo.com/search/video?p=$REPLY&x=0&y=0

come faccio a dare un valore alla variabile da terminale?
Tornare in alto Andare in basso
Vedere il profilo dell'utente
BlackLight
Moderatore
Moderatore


Numero di messaggi: 277
Età: 25
Data d'iscrizione: 22.08.07

MessaggioOggetto: Re: Input in Bash   Gio Dic 27, 2007 4:38 pm

Codice:
read REPLY

_________________
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CM/CC/E/IT/LS/M d-(--) s:- a-- C+++$ UBL++++$ P+++ L+++++$ E- W+++ N+ o? K? w-- !O !M>+ !V PS+++ PE-- Y++ PGP+ !t !5 !X R+ tv-- b++>+++ DI? D+ G>+++ e++>++++ h r++ y+++
------END GEEK CODE BLOCK------

Codice:
blacklight@nightmare:/$ touch figa
touch: cannot touch `figa': Permission denied
Tornare in alto Andare in basso
Vedere il profilo dell'utente http://blacklight.gotdns.org
black hole
membro
membro


Numero di messaggi: 90
Data d'iscrizione: 03.10.07

MessaggioOggetto: Re: Input in Bash   Ven Dic 28, 2007 7:33 pm

grazie black...sembra fin troppo intuibile come comando...
Tornare in alto Andare in basso
Vedere il profilo dell'utente
black hole
membro
membro


Numero di messaggi: 90
Data d'iscrizione: 03.10.07

MessaggioOggetto: Re: Input in Bash   Ven Dic 28, 2007 8:23 pm

conuque il codice esatto è questo:
Codice:

#!/bin/bash
REPLY=
echo "che video devo cercare?(parole chiave)"
read REPLY
firefox http://www.metacafe.com/tags/$REPLY
firefox http://www.youtube.com/results?search_query=$REPLY&search=Search
firefox http://video.yahoo.com/search/video?p=$REPLY&x=0&y=0
Tornare in alto Andare in basso
Vedere il profilo dell'utente
black hole
membro
membro


Numero di messaggi: 90
Data d'iscrizione: 03.10.07

MessaggioOggetto: Re: Input in Bash   Ven Dic 28, 2007 8:55 pm

ed ecco qua una versione più avanzata
Codice:

#!/bin/bash

SITO=
REPLY=

echo '
che video devo cercare?(parole chiave)'

read PAROLACHIAVE

echo "
scegli un sito di quest'elenco:
metacafe
youtube
yahoo
google
"

read SITO

if [ $SITO = 'metacafe' ]; then
   firefox http://www.metacafe.com/tags/$PAROLACHIAVE
   exit
fi

if [ $SITO = 'youtube' ]; then
   firefox http://www.youtube.com/results?search_query=$PAROLACHIAVE&search=Search
   exit
fi

if [ $SITO = 'yahoo' ]; then
   firefox http://video.yahoo.com/search/video?p=$PAROLACHIAVE&x=0&y=0
   exit
fi

if [ $SITO = 'google' ]; then
   firefox http://video.google.it/videosearch?q=$PAROLACHIAVE
else
   echo "
non posso cercare i video in quel sito"
fi

azz...per ora si può mettere solo una parola chiave
Tornare in alto Andare in basso
Vedere il profilo dell'utente
black hole
membro
membro


Numero di messaggi: 90
Data d'iscrizione: 03.10.07

MessaggioOggetto: Re: Input in Bash   Dom Dic 30, 2007 2:26 pm

l'ultimissima versione...non ha più bisogno di un terminale e sfrutta il caro zenity:
Codice:

#!/bin/bash

PAROLACHIAVE=$(zenity --entry --text='Che video devo cercare?(parola chiave)')

SITO=$(zenity  --list  --text "Dove cerdo il video?" --radiolist  --column "Scegli" --column "Sito" "" metacafe "" youtube "" yahoo "" google "" veoh)

if [ $SITO = 'metacafe' ]; then
   firefox http://www.metacafe.com/tags/$PAROLACHIAVE
   exit
fi

if [ $SITO = 'youtube' ]; then
   firefox http://www.youtube.com/results?search_query=$PAROLACHIAVE&search=Search
   exit
fi

if [ $SITO = 'yahoo' ]; then
   firefox http://video.yahoo.com/search/video?p=$PAROLACHIAVE&x=0&y=0
   exit
fi

if [ $SITO = 'google' ]; then
   firefox http://video.google.it/videosearch?q=$PAROLACHIAVE
   exit
fi

if [ $SITO = 'veoh' ];then
   firefox 'http://www.veoh.com/search.html?numResults=20&action=search&type=&fromSearchForm=fromSearchForm&search='$PAROLACHIAVE
fi

ancora una sola parola chiave...
Tornare in alto Andare in basso
Vedere il profilo dell'utente
 

Input in Bash

Vedere l'argomento precedente Vedere l'argomento seguente Tornare in alto 
Pagina 1 su1

Permesso del forum:Non puoi rispondere agli argomenti in questo forum
Xhack :: Programmazione :: Other-