Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SCRIPT] Rilevare se sono collegato a internet ??? [RISOLTO]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Mon Nov 22, 2004 3:03 pm    Post subject: [SCRIPT] Rilevare se sono collegato a internet ??? [RISOLTO] Reply with quote

Qualcuno conosce il modo per sapere se la propria macchina e' connessa a internet ???

Mi Servirebbe uno script Bash o Python o Ruby o Perl o C
che mi dica se la mia macchina e' connessa a internet...

Qualcuno sa' come fare ???
_________________
http://th30z.netsons.org/


Last edited by _sys/sid on Mon Nov 22, 2004 5:39 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30965
Location: here

PostPosted: Mon Nov 22, 2004 3:09 pm    Post subject: Reply with quote

Si fai un while che ogni tot di tempo fa un ping su un sito e vedi se sei connesso.
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Mon Nov 22, 2004 3:15 pm    Post subject: Reply with quote

forse mi sono espresso male...
Devo controllare che il pc che ho in uso 'in questo momento' sia connesso a internet...
non c'e' qualche cosa in /proc che mi dica se sono connesso o meno ???
_________________
http://th30z.netsons.org/
Back to top
View user's profile Send private message
Ferdinando
Veteran
Veteran


Joined: 25 Nov 2003
Posts: 1027
Location: Gaeta (LT) - Italy

PostPosted: Mon Nov 22, 2004 3:22 pm    Post subject: Reply with quote

In /proc non ci può essere nulla perché puoi connetterti in mille modi molto diversi tra loro: ad esempio se sei connesso con la ethernet tu non sei fisicamente connesso ad internet, ma solo ad un router connesso ad internet. Penso però che a te interessi un'interfaccia particolare, ad esempio ppp. E' così?

ciao
_________________
La risposta, non la devi cercare fuori, la devi cercare dentro di te: e però è SBAGLIATA!
-- Corrado Guzzanti, "Pippo Chennedy Show", 1997
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30965
Location: here

PostPosted: Mon Nov 22, 2004 3:24 pm    Post subject: Reply with quote

Appunto che c'e' di sbagliato a fare un ping? Questo non dipende come sei connesso (wifi o ethernet,..)
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Mon Nov 22, 2004 3:25 pm    Post subject: Reply with quote

_sys/sid wrote:
forse mi sono espresso male...
Devo controllare che il pc che ho in uso 'in questo momento' sia connesso a internet...
non c'e' qualche cosa in /proc che mi dica se sono connesso o meno ???


Penso che la cosa più semplice sia fare quello che ti ha detto fedeleallalinea.
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Mon Nov 22, 2004 3:30 pm    Post subject: Reply with quote

Mi connetto con wvdial quindi ppp...
Il Ping lo dovrei fare sul mio ip... Giusto ???

Ma non c'e' un altro metodo ???
_________________
http://th30z.netsons.org/
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Mon Nov 22, 2004 3:34 pm    Post subject: Reply with quote

_sys/sid wrote:
Mi connetto con wvdial quindi ppp...
Il Ping lo dovrei fare sul mio ip... Giusto ???
[CUT]


Verso un server esterno ad esempio google.com

_sys/sid wrote:

[CUT]
Ma non c'e' un altro metodo ???


Se usi solo ppp puoi fare un grep di ifconfig per vedere se hai un'interfaccia ppp UP.
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30965
Location: here

PostPosted: Mon Nov 22, 2004 3:34 pm    Post subject: Reply with quote

No lo fai per esempio su google.ch
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Ferdinando
Veteran
Veteran


Joined: 25 Nov 2003
Posts: 1027
Location: Gaeta (LT) - Italy

PostPosted: Mon Nov 22, 2004 3:34 pm    Post subject: Reply with quote

_sys/sid wrote:
Mi connetto con wvdial quindi ppp...
Il Ping lo dovrei fare sul mio ip... Giusto ???

Ma non c'e' un altro metodo ???


No, devi pingare un server su internet. In alternativa,
Code:
ifconfig ppp0

se restituisce
Code:
ppp0: error fetching interface information: Device not found

non sei connesso: puoi utilizzare l'output di grep come booleano.

ciao
_________________
La risposta, non la devi cercare fuori, la devi cercare dentro di te: e però è SBAGLIATA!
-- Corrado Guzzanti, "Pippo Chennedy Show", 1997
Back to top
View user's profile Send private message
randomaze
Bodhisattva
Bodhisattva


Joined: 21 Oct 2003
Posts: 9985

PostPosted: Mon Nov 22, 2004 3:37 pm    Post subject: Reply with quote

Ferdinando wrote:
No, devi pingare un server su internet.


Ad esempio il server DNS ;-)
_________________
Ciao da me!
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Mon Nov 22, 2004 3:37 pm    Post subject: Reply with quote

Caspita tre post in contemporanea :) A momenti battiamo un record :D
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
Ferdinando
Veteran
Veteran


Joined: 25 Nov 2003
Posts: 1027
Location: Gaeta (LT) - Italy

PostPosted: Mon Nov 22, 2004 3:38 pm    Post subject: Reply with quote

gutter wrote:
Caspita tre post in contemporanea :) A momenti battiamo un record :D

:lol: :lol: :lol: :lol: :lol:
_________________
La risposta, non la devi cercare fuori, la devi cercare dentro di te: e però è SBAGLIATA!
-- Corrado Guzzanti, "Pippo Chennedy Show", 1997
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30965
Location: here

PostPosted: Mon Nov 22, 2004 3:39 pm    Post subject: Reply with quote

gutter wrote:
Se usi solo ppp puoi fare un grep di ifconfig per vedere se hai un'interfaccia ppp UP.

Anche l'eth0 se usa ifplugd
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Mon Nov 22, 2004 3:43 pm    Post subject: Reply with quote

fedeliallalinea wrote:
gutter wrote:
Se usi solo ppp puoi fare un grep di ifconfig per vedere se hai un'interfaccia ppp UP.

Anche l'eth0 se usa ifplugd


Mai usato :cry:
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
oRDeX
Veteran
Veteran


Joined: 19 Oct 2003
Posts: 1325
Location: Italy

PostPosted: Mon Nov 22, 2004 3:47 pm    Post subject: Reply with quote

Ancora più correttamente potresti fare:
Code:
ifconfig ppp0 |grep RUNNING

se ti sestituisce qualcosa vuol dire che l'interfaccia è UP correttamente, perchè fare ifconfig ppp0 potrebbe restituirti qualcosa ma magari non sei comunque connesso.
Back to top
View user's profile Send private message
Giangi
n00b
n00b


Joined: 01 Oct 2003
Posts: 41
Location: Rome - ITALY -

PostPosted: Mon Nov 22, 2004 3:53 pm    Post subject: Re: [SCRIPT] Rilevare se sono collegato a internet ??? Reply with quote

_sys/sid wrote:
Qualcuno conosce il modo per sapere se la propria macchina e' connessa a internet ???

Mi Servirebbe uno script Bash o Python o Ruby o Perl o C
che mi dica se la mia macchina e' connessa a internet...

Qualcuno sa' come fare ???



prova anche netstat -t
_________________
Un sistema è sicuro quando è spento.
-The Giangi-
Back to top
View user's profile Send private message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Mon Nov 22, 2004 5:38 pm    Post subject: Reply with quote

Grazie Mille a tutti...
_________________
http://th30z.netsons.org/
Back to top
View user's profile Send private message
Panda
Apprentice
Apprentice


Joined: 31 Jul 2003
Posts: 223
Location: Cremona <=> Catania

PostPosted: Mon Nov 22, 2004 6:33 pm    Post subject: Reply with quote

In un piccolo script per connettermi/disconnettermi uso questa riga per vedere se la mia interfaccia ppp0 esiste:
Code:
cat /proc/net/dev|grep ppp > /dev/null ; echo $?
Se ritorna 0 esiste e quindi sei connesso, altrimenti no. E' piu' utile visto che ifconfig devi eseguirlo da root...
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Mon Nov 22, 2004 6:42 pm    Post subject: Reply with quote

Ma non basterebbe dare un semplice /sbin/ifconfig ?
_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
_sys/sid
Guru
Guru


Joined: 27 Aug 2004
Posts: 346
Location: Asola (Mantova)

PostPosted: Mon Nov 22, 2004 6:45 pm    Post subject: Reply with quote

@panda grazie mille...

cosi evitiamo il problema di root con ifconfig...
_________________
http://th30z.netsons.org/
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Mon Nov 22, 2004 7:00 pm    Post subject: Reply with quote

Panda wrote:

[CUT]
E' piu' utile visto che ifconfig devi eseguirlo da root...


ifconfig lo puoi eseguire anche da utente normale.
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30965
Location: here

PostPosted: Mon Nov 22, 2004 7:14 pm    Post subject: Reply with quote

Neomubumba wrote:
Ma non basterebbe dare un semplice /sbin/ifconfig ?

Si puoi aggingere anche al tuo path /sbin cosi' anche da utente normale puoi dare semplicemente ifconfig
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Panda
Apprentice
Apprentice


Joined: 31 Jul 2003
Posts: 223
Location: Cremona <=> Catania

PostPosted: Mon Nov 22, 2004 7:16 pm    Post subject: Reply with quote

[quote="gutter"]
Panda wrote:
ifconfig lo puoi eseguire anche da utente normale.


ca**o non lo sapevo! non avevo fatto caso che /sbin/ non fosse nel path di un utente normale e credevo che potesse eseguirlo solo root! :oops:
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Mon Nov 22, 2004 10:59 pm    Post subject: Reply with quote

Io l'ho detto ma sono un niubbo, era un ricordo del handbook di gentoo che ti dice prima di provare (o anche dopo che hai configurato la rete) a configurare la rete di dare /sbin/ifconfig.

Poi usando gentoo mi sono accorto che posso sempre darlo da utente normale. Infatti anche se è un controsenso quando do /etc/init.d/net.eth0 stop faccio sempre una prova se me lo segnala /sbin/ifconfig.
_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum