Xhack
Vuoi reagire a questo messaggio? Crea un account in pochi click o accedi per continuare.
Xhack

Un forum dedicato all'hacking
 
IndiceIndice  PortalePortale  CercaCerca  Ultime immaginiUltime immagini  RegistratiRegistrati  Accedi  

 

 Input in Bash

Andare in basso 
2 partecipanti
AutoreMessaggio
black hole
membro
membro
black hole


Numero di messaggi : 90
Data d'iscrizione : 03.10.07

Input in Bash Empty
MessaggioTitolo: Input in Bash   Input in Bash EmptyGio Dic 27, 2007 3: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?
Torna in alto Andare in basso
BlackLight
Moderatore
Moderatore
BlackLight


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

Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash EmptyGio Dic 27, 2007 6:38 pm

Codice:
read REPLY
Torna in alto Andare in basso
http://blacklight.gotdns.org
black hole
membro
membro
black hole


Numero di messaggi : 90
Data d'iscrizione : 03.10.07

Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash EmptyVen Dic 28, 2007 9:33 pm

grazie black...sembra fin troppo intuibile come comando...
Torna in alto Andare in basso
black hole
membro
membro
black hole


Numero di messaggi : 90
Data d'iscrizione : 03.10.07

Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash EmptyVen Dic 28, 2007 10: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
Torna in alto Andare in basso
black hole
membro
membro
black hole


Numero di messaggi : 90
Data d'iscrizione : 03.10.07

Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash EmptyVen Dic 28, 2007 10: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
Torna in alto Andare in basso
black hole
membro
membro
black hole


Numero di messaggi : 90
Data d'iscrizione : 03.10.07

Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash EmptyDom Dic 30, 2007 4: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...
Torna in alto Andare in basso
Contenuto sponsorizzato





Input in Bash Empty
MessaggioTitolo: Re: Input in Bash   Input in Bash Empty

Torna in alto Andare in basso
 
Input in Bash
Torna in alto 
Pagina 1 di 1
 Argomenti simili
-
» mascherare un'input con asterischi..

Permessi in questa sezione del forum:Non puoi rispondere agli argomenti in questo forum.
Xhack :: Programmazione :: Other-
Vai verso: