• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Need helps with my script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need helps with my script


  • Subject: Need helps with my script
  • From: Thomas Labarre <email@hidden>
  • Date: Mon, 05 Jan 2015 11:17:49 +0100

Hello list
I have an issue with the first part of my script. I am a beginner in Applescript and I can not define my variable "test_ping" in my block.
The script is to define the user if it is connected to the network or not.
If it is not, a simple message pop up, if it is, an information window gives the IP address of ethernet or wifi and the default router
I have a worry in the first part. If my gateway value is not correct, I have an error message other than the one I set.
My problem comes when no network interface is defined

Thank you for your help
-- Début du script
display dialog "Test de l'activité réseau. Patience ..." buttons {"Ω Merci Ω"} with icon note giving up after 3 with title "Vérification de la connectivité réseau"
set IP_127 to "127.0.0.1" -- pas d'IP renseignée
set no_ping to "Request timeout for icmp_seq 0" -- pas de ping vers la passerelle
set no_host to "ping: sendto: Host is down" -- pas de ping vers la passerelle
set routeur_dectect to do shell script "netstat -rn | awk 'NR==5{print $2}'" -- Determination de la passerelle
set test_ping to do shell script "ping -i 2 -t 2 " & routeur_dectect -- test ping passerelle
try
    if (routeur_dectect contains IP_127) or (test_ping contains no_ping) or (test_ping contains no_host) then
        set MessagePasDeReseau to "Pas de connexion au réseau détectée.           Veuillez vérifier que votre câble est bien connecté ou que le WIFI est bien configuré"
        display dialog MessagePasDeReseau buttons " FIN " giving up after 20 with icon stop with title "Contacter le Service Informatique"
    else if (routeur_dectect does not contain IP_127) or (test_ping does not contain no_ping) or (test_ping does not contain no_host) then
        set Connecter to "Votre ordinateur est connecté au réseau " -- test de connexion OK
        set AfficherConnecter to display dialog Connecter buttons {" Afficher mon IP "} default button 1 with icon note with title "La Connexion a Réussi !!"
        set boutonAppuye to button returned of AfficherConnecter
        if boutonAppuye = " Afficher mon IP " then
            set Affiche_IP to "Suis-je-connecteV2.app/Contents/Resources/Scripts/affiche_ip.sh"
            tell application "Finder"
                activate
                set currentPath to container of (path to me) as text
            end tell
            set currentPathUnix to POSIX path of currentPath
            set UseScript to currentPathUnix & Affiche_IP
            do shell script quoted form of (UseScript)
        end if
    end if
end try
-- Fin du script
 
--


Thomas
Technicien Support

GIP Sym@ris
Pôle Infogérance
Pavillon 1
27
rue du 4ème RSM, B.P. 29
F-68250 ROUFFACH
Tél bureau : +33 (0)3 89 78 71 99
Courriel : email@hidden
Web : http://www.symaris.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Need helps with my script
      • From: 2551 <email@hidden>
  • Prev by Date: Re: Permitting a script to only run on OS X Yosemite
  • Next by Date: JavaScript for Automation curiosity (was "Script that "Tells" Finder just Focuses on Finder instead of running")
  • Previous by thread: Re: Permitting a script to only run on OS X Yosemite
  • Next by thread: Re: Need helps with my script
  • Index(es):
    • Date
    • Thread