Trying to set a delay in an Applescript for VPN connection

I need to be able to set some routes upon opening a particular VPN connection so I did some searching and found a really simple Applescript that does the job. Problem is it tries to set the routes before the VPN actually connects so the routes don't go in.
I added in a 10 second delay which does the trick, but I'm thinking there has to be a way to do this that waits until the VPN actually connects before continuing - so if it takes 5 seconds or 10 or whatever, it waits.
The other thing I'm doing that I think is bad is I'm sending a route delete command before sending the add command. Why? Because if I don't and for some reason the route is partially in the table, it doesn't give an error and ends up not routing. Again, probably a better way to do this.
Here is my current script"
-- Connect Work VPN
tell application "System Events"
tell current location of network preferences
set VPNservice to service "Work" -- name of the VPN service
if exists VPNservice then connect VPNservice
end tell
end tell
delay 10
set gateway to "x.x.x.x" -- omitted here for security
do shell script "route delete 192.168.25.0/24 " & gateway with administrator privileges
do shell script "route delete 192.168.20.0/24 " & gateway with administrator privileges
do shell script "route add 192.168.25.0/24 " & gateway with administrator privileges
do shell script "route add 192.168.20.0/24 " & gateway with administrator privileges
Any suggestions??
Thanks.

you might want to try asking in the Applescript forum under OS X technologies.
I don't have any VPN connections so can't test anything but applescript dictionary for system events indicates that configuration property of a service has a boolean property "connected". so just run a loop with, say, 1 second delay until this porperty becomes true. presumably it would be something along the lines
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
tell application "System Events"
tell current location of network preferences
set VPNservice to service "Work" -- name of the VPN service
if exists VPNservice then connect VPNservice
repeat until (connected of current configuration of VPNservice)
delay 1
end repeat
end tell
end tell
set gateway to "x.x.x.x" -- omitted here for security
do shell script "route delete 192.168.25.0/24 " & gateway with administrator privileges
do shell script "route delete 192.168.20.0/24 " & gateway with administrator privileges
do shell script "route add 192.168.25.0/24 " & gateway with administrator privileges
do shell script "route add 192.168.20.0/24 " & gateway with administrator privileges</pre>

Similar Messages

  • I'm trying to set up a iTunes allowance account for my 11 year old daughter, I set up the account but put in the wrong email address, now it's trying to send the verification email to an old addy I no longer have access to. Help.

    I'm trying to set up a iTunes allowance account for my 11 year old daughter, I set up the account but put in the wrong email address, now it's trying to send the verification email to an old addy I no longer have access to. Help.
    I've tried looking at my own itunes account but I cannot seem to find the allowance account, it says I currently have zero allowance accounts.
    All I want to do is change the assigned email address.

    Who is the email provider? Not all accounts can be set up as POP3

  • Hi there. I bought and downloaded photoshop elements 13 today. When I tried to set it up and was prompted for the serial number, the one I was given and subsequently entered ( correctly ,I checked numerous times) was seems invalid. What's the next step?!

    hi there, I bought and downloaded Adobe photoshop elemts 13 today. When trying to set it up, I was prompted for the serial number which upon being entered was deemed invalid. I know the serial number is the correct one. What is the next step, how do I contact Adobe store?!?

    Error "The serial number is not valid for this product" | Creative Suite
    if that doesn't help, contact adobe support by clicking here and, when available, click 'still need help', https://helpx.adobe.com/contact.html

  • Informix: Error while trying to set up start or end key for index read

    Hi all
    Im moving an application from weblogic 6.1 to 8.1, we're using informix as our databasemanager and are using informix's XA driver. However im running into the following error:
    SQL State: IX000, Exception: java.sql.SQLException: [Internal] Error while trying to set up start or end key for index read [fmstopset_release],
    SQL ErrorCode: -9847, Error Message: [Internal] Error while trying to set up start or end key for index read [fmstopset_release], RSAM ErrorCode: -101
    ...while accessing a table.
    The same code runs fine twice, but the third and following times it fails with the above error code. I've tried setting the various XA flags available in the weblogic console but with no success so far.
    Anyone have any input to this problem? Ive not seen many postings about this error out in the cyberspace and the fews ive seen never gets any response...so i just have to hope anyone in here know anything about it.
    Best regards
    JM

    Ulf Akerberg wrote:
    Hello
    I managed to work around my problem by setting the "statement cache size" in the jdbc connection pool to 0. At least that seems to be a work around, im not fully happy with it.
    I attach the stack trace from the exception, perhaps it will give someone an idea.
    Btw, we're using sun.jdbc.rowset.ExtendedCachedRowSet to populate the resultset to a "disconnected resultset" which the application works with instead of the resultset. Any statements and resultsets that are created are closed before returning the ExtendedCachedRowSet to the application.
    If the application works when statement caching is turned off, then it implies a bug in the
    informix driver to do with re-using a prepared statement. Is the PreparedStatement used
    the same way each time? (the one at AbstractDAO.java:166) What I mean to ask is, If/when
    this statement is created with a given SQL string, are the parameters for that SQL always
    set the same way?
    thanks,
    Joe
    >
    2004-09-10 15:45:05,603 ERROR [ExecuteThread: '14' for queue: 'weblogic.kernel.Default'] - SQLException: Generic SQL failed:
    SELECT d.*,dt.dokument_typ FROM dokument d, OUTER dokument_typ dt WHERE d.dok_typ_id = dt.dok_typ_id AND d.dokument_id = ? ( 0:894),
    SQL State: IX000, Exception: java.sql.SQLException: [Internal] Error while trying to set up start or end key for index read [fmstopset_release],
    SQL ErrorCode: -9847, Error Message: [Internal] Error while trying to set up start or end key for index read [fmstopset_release], RSAM ErrorCode: -101
    java.sql.SQLException: [Internal] Error while trying to set up start or end key for index read [fmstopset_release]
         at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3105)
         at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3419)
         at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2282)
         at com.informix.jdbcx.IfxXASqli.receiveMessage(IfxXASqli.java:119)
         at com.informix.jdbc.IfxSqli.sendStatementQuery(IfxSqli.java:1464)
         at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1403)
         at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1333)
         at com.informix.jdbc.IfxResultSet.executeQuery(IfxResultSet.java:223)
         at com.informix.jdbc.IfxStatement.executeQueryImpl(IfxStatement.java:843)
         at com.informix.jdbc.IfxPreparedStatement.executeQuery(IfxPreparedStatement.java:244)
         at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:80)
         at infrastructure.dao.AbstractDAO.genericSqlRead(AbstractDAO.java:166)
         at se.migrationsverket.dhs.domain.dao.DokumentDAO.findByDokId(DokumentDAO.java:64)
         at se.migrationsverket.dhs.domain.dao.DokumentDAO.findByDokId(DokumentDAO.java:43)
         at se.migrationsverket.dhs.generator.impl.pipeline.LoadDocumentPipeline.buildMultiDocument(LoadDocumentPipeline.java:99)
         at se.migrationsverket.dhs.generator.impl.pipeline.LoadDocumentPipeline.process(LoadDocumentPipeline.java:53)
         at se.migrationsverket.dhs.generator.impl.DHSDocumentGenerator.loadDocument(DHSDocumentGenerator.java:63)
         at se.migrationsverket.dhs.generator.DocumentGeneratorInternalHelper.loadDocument(DocumentGeneratorInternalHelper.java:129)
         at se.migrationsverket.dhs.services.document.internal.InternalDocumentManagerBean.loadDocument(InternalDocumentManagerBean.java:185)
         at se.migrationsverket.dhs.services.document.internal.InternalDocumentManager_6sz7e8_EOImpl.loadDocument(InternalDocumentManager_6sz7e8_EOImpl.java:532)
         at se.migrationsverket.dhs.action.documentgenerator.GeneratorAction.load(GeneratorAction.java:147)
         at se.migrationsverket.dhs.action.documentgenerator.GeneratorAction.perform(GeneratorAction.java:49)
         at se.migrationsverket.dhs.servlet.AbstractController.doPost(AbstractController.java:84)
         at se.migrationsverket.dhs.servlet.AbstractController.doGet(AbstractController.java:54)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Regards
    JM

  • Hey I bought an iPhone off gumtree and everything was well. But then I tried to set it up and it asked for the apple if of the previous owner and so I asked him for it his Apple ID but refused to tell me so I can not use the phone. how do I fix this?

    Hey I bought an iPhone off gumtree and everything was well. But then I tried to set it up and it asked for the apple if of the previous owner and so I asked him for it his Apple ID but refused to tell me so I can not use the phone. how do I fix this?

    Contact them back and have them follow these instructions  Find My iPhone Activation Lock: Removing a device from a previous owner’s account - Apple Support

  • Ipad trying to set up iSOS 8 and cant get past connect to itunes. Each time itunes gets to end of sync it says 'can't sync as not set up' yet that is what I'm trying to do!

    Hi,
    Trying to set up the ipad (a few years old) after updating to iSOS 8 and we are stuck at the set up stage. It seems to be stuck at the connect to itunes page. When we connect to itunes it will start sync...then gets the end and says it can't sync as its not set up...but that is what i'm trying to do!! Help!

    Which version of firefox are you using? Please update to the latest version if you have not already.
    Also are you putting capital letters into the email field? Try using all lower case.

  • Unable to set manual IP address for VPN connection

    Recently a VPN connection with a client stopped working. They changed phone companies and changed some of the IP addresses.
    After alerting them I could no longer log in, I received the new server address which I can log in with it,
    BUT my computer is assigned a dynamic address that is already in use on their network. This causes my computer to *not* be connected to their network, even though I am inside their firewall; therefore I cannot adjust the database files I need to.
    I have tried to set the VPN (PPTP) connection TCP/IP address IPv4 manually, using the static address they just gave me. But each time I connect, [I believe] their router assigns me an address that is already in use.
    They do not use IPv6.
    Can anyone give me direction on how to make the manual IP address *stick*?
    The tech person at the site keeps telling me it is a problem with my "Mac, because with Windows.... blah, blah, blah".
    I am pretty sure this is not the case and in fact I was the one who let her know I was receiving a duplicate address.
    Your VPN expertise is really appreciated.
    Thanks in advance,
    Michele

    Hi,
    Please make sure the Ad hoc connection IP adress is at the same range with your local connection. In addition, how about recreate the ad hoc connection for test, please have a try.
    If problem persists, please use Network troubleshooter in Action Center to fix this problem for test.
    Roger Lu
    TechNet Community Support

  • I have an iPhone 4 and an iPod 4th gen linked to the same email address and apple ID. I am trying to set up a new email address for the iPod so a family member can use it but it doesn't want to recognize the new email account. Where am I going wrong?

    I have an iPhone 4 and a 4th gen iPod linked to the same email address and apple ID. I am trying to change the email address on the iPod so a family member can use it but when I do it says it doesn't recognize the email address. Where am I going wrong ? I just want them to be able to iMessage and email without having to use my email address.

    The procedure is Settings>Messages>Send & Receive at>You can be reached by iMessages at>Add another email address. The email address has to be a valid working email address, obviously. Apple should verify the email address and you have to go to the inbox of that email account, read the verification email from Apple and follow the inductions in the email in order to complete the verification. Then you go back to the settings, uncheck your email address and check the new email address to be used as the contact email address.

  • I am trying to set up a new Apple ID for my 2 sons.  It says that both of their emails are already in use for someone else Apple ID.  They don't have other emails.  What do I do?

    Apple ID already in use by someone else.

    Cara,
    If those email addresses are already in use somewhere else, you can get new email addresses for your kids.  You can do this via your ISP, or by one of the free email services such as hotmail, yahoo, or gmail.

  • I am trying to set up a new ipad 2 for my wife.

    I found my name and number under her contacts on the new ipad. I chose to send a text message to MY phone number from HER ipad. When I recieved the message, it showed up as coming from my name... WHY?

    Cara,
    If those email addresses are already in use somewhere else, you can get new email addresses for your kids.  You can do this via your ISP, or by one of the free email services such as hotmail, yahoo, or gmail.

  • I just upgraded to Lion. I was trying to set up the iCloud and it asked for my "login" keychain password. I've never been asked for that before. I've tried every password I can think of and nothing works. Is there a way to reset the keychain password?

    I just upgraded to Lion. I was trying to set up iCloud and it asked for my "login" keychain password. I've never been asked for the keychain password before. I've tried every password I can think of and nothing works. I'm normally asked for the password to my machine when upgrading software, signing on, etc. but this is different apparently. I tried the same password and it didn't work either. I read a couple of posts and they all want to take me through Applications/Utilities but that requires knowing your password in order to change it. I don't know it. Don't remember ever setting up a keychain password. Does anyone know how to change the keychain password if you don't know the keychain password???

    Most of the time your Keychain password is the same as your login password. If you configured your computer to log you in automatically, you may not have used your login password in so long you forgot it.
    There is no way to retrieve the "login" Keychain password, but you can reset the Keychain from the Preferences menu: select it in the Keychain Access menu and select "Reset My Default Keychain". This will create a new, empty Keychain but the old one will be saved should you ever remember its password.
    The result of this is that you will have to supply passwords for everything that requires it, since without your Keychain they will no longer automatically fill themselves. However, once you supply them and store them in your new Keychain, they will be remembered.

  • I becane lost trying to set jon do I lost my bookmarks everhthing I foud a file call bookrarks back up how to I get this to the browser

    I was trying to set up jodonfox it kept asking for a profile i kept adding them then i deleted them all. lost my bookmarks my home page set everything I re-downloaded Firefox no luck I found a file called backup up bookmarks form the system restore I suppose by do not have a clue how to get it back into the browser

    See also:
    *https://support.mozilla.org/kb/Recovering+important+data+from+an+old+profile
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • New ARCH setup trying to set a 32 bit bundle system

    I just finish my isntallation of arch and KDE, I tried several DMs until KDE seems the one that won, now I am trying to set a bundled 32 bit system :  https://wiki.archlinux.org/index.php/In … _in_Arch64 but as any of the other documentation this is referencing to use rc.conf and I am using systemd now since it is a new install.
    can i just use rc.conf for this or any guidance on running that arch32 scritp?
    I already downloaded all the lib32 libraries for X86_64 but it appears I am still running into issues running some 32 bit app, so trying to set a separate 32 bit system for it.

    Its a bash script, you can still run it using rc.d start if you have initscripts installed.
    Slightly longer version, write your own small service file to handle it (starting/stopping the script).
    Noone has written a 'native' systemd (there isn't actually such a thing, but whatever) arch32 script yet. Xyne says he will get round to it someday, but he's not yet on systemd and doesn't yet have the time. Check the arch32-light package in the AUR for details.

  • NorthWinds DB-Can't set READ DATA/READ DESIGN permissions for MSysObjects

    I tried to set READ DATA and READ DESIGN for object MSysObjects as stated in the tutorial for Migrating Northwind Access DB but I get a "You can't change permissions for 'MSysObjects'". The error message says that to change permissions for this object, I must have Administer permission for it. How do I get permissions? Can someone please help.

    Hi Robert,
    Apologies for the delay in responding, but I see you've since found a workaround yourself, which is great.
    As a minimum we recommend that a user applies the read data/read design permissions, but users with "Update Data" have sufficient permissions in order to create a connection to the MS Access MDB file via Oracle SQL Developer. Generally, once you're in the Admins group, there should be no issues setting the required permissions of the MSys~ tables. However, I have known MS Access to be a little temperamental when it comes to allowing for permissions settings on these tables. If necessary, go to the "Change Owner" tab of the "User and Group Permissions" dialog, and set the New Owner of the table in question to Admin.
    Regards,
    Hilary

  • Need help setting up a new email account for my wife.

    I've been trying to set up a separate email account for my wife with no success. I've gone to Preferences clicked the plus sign, it then asks for full name (my wifes'?) email address (would that be the one I pick for her or my email address?) and password- I'm assuming that's the password I use to get my email. It tells me it's checking connection to mail server and then says login to "POP failed".
    Thanks for the help.
    Richard

    New email accounts should be created and set up first with your email service provider--contact them for information about how to do that. Just making up a new address and typing it into Mail's preferences doesn't create a new email account.
    Edited to add: In addition, you probably want to establish a new user account for your wife on your Mac, so that you and she have separate folders and inboxes for your mail, once she has her own account set up. Separate user accounts also mean the two of you can have separate bookmarks on your browsers, separate document folders, and so on--almost as if you each had your own computer.
    Message was edited by: Jay Bullock

Maybe you are looking for

  • Itunes will no longer sync...with my Iphone

    Itunes will no longer sync...need to upgrade it?  On the computer or on my phone?  When I went to the Itunes site - and attempted to upgrade ITunes, it said i needed to upgrade my OX.  what do I have to do

  • Price changes in Scheduling Agreement

    Hi, What is the best way to handle price changes in a Scheduling Agreement? From what I saw, the validity periods of the prices maintained in a scheduling Agreement is based on the GR date. Is there any way we can change this? The requirement is to m

  • In iPhoto 11. 9.4.3 cropping won't work

    Prior to Christmas I successfully compiled an iPhoto Book and everything was hunkydory. Yesterday, I attempted to crop a photo in the same manner as before using my one and only Trackpad, and it reduced the size of the photo onto a white background a

  • Aspire One Lid issue

    Hello Folks, I got a brandnew acer aspire one and most things already work, but the "lid suspend" doesn't work properly. When I close the lid, it goes to suspend, but after opening(which doesn't wake up due hardware) and pressing the power button it

  • Query performance tuning beyond entity caching

    Hi, We have an extremely large read-only dataset stored using BDB-JE DPL. I'm seeking to tune our use of BDB while querying, and I'm wondering what options we have beyond simply attempting to cache more entities? Our expected cache hit rate is low. C