Change "Location" with a script?

Dear all,
I am working in two different (network) environments and need to change both network settings (proxy, ...) and also computer settings (CUPS server) and some environment variables depending on my physical location. For the latter two I have a little bash script that does that conveniently.
But changing the network always requires a few clicks extra... I was wondering if it was possible to change the network environment ("Location" in the Apple menu) by a script (I tried with AppleScript and Automator but didn't find anything) or to run a script automatically whenever I change the Location. This way I would only have to run either the script or change the Location to adjust all settings.
Can anyone help me here?
Thanks a lot,
Leonard

Hi Pierre,
Thank you. Your point number 3 was the solution. (I actually wanted to mark your message as "solved"... Now I have marked the question as "answered").
While this works, ideally I would like to have one script that does both the changes to the shell (for this I already have a shell script) and the changes to Mac OS.
On http://developer.apple.com/Mac/library/documentation/AppleScript/Conceptual/Appl eScriptX/Concepts/workwithas.html I found a way to call an AppleScript from the shell (using the #!/usr/bin/osascript interpreter) -- but if I run the script you sent I get
142:166: execution error: No user interaction allowed. (-1713)
In fact I would prefer the script to run without user interaction, i.e. to just put in the name of the location that I want to switch to and not display a selection box. I would then just create two or three scripts for my most frequently used locations. I tried a few variants but I didn't manage to set 'R' which is probably the variable containing the new location to a fixed value. Could I ask you again for help with this?
Thanks again,
Leonard

Similar Messages

  • "Table" changes locations with different browsers

    The the body of my website is a JPEG, and I have a table that contains a form. I am trying to line up the form with the text that is in the background, but when I get it right looking in one browser, it is completely wrong in another.
    Any advice on how to fix this would be greatly appreciated! The specific website is: http://www.high-road.org/contact.html
    Here is my code..
    <meta name="description" content="High Road is a Christian Celtic Music Group based in Memphis, TN.">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    .style1 { font-size: 20px;
    font-family: "Times New Roman", Times, serif;
    .style5 {font-size: 20px}
    .style9 {font-size: 28px}
    -->
    </style>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    //-->
    </script>
    </head>
    <body onLoad="MM_preloadImages('IMAGES/menubarroll_2.jpg','IMAGES/menubarroll_3.jpg','IMAGES/me nubarroll_4.jpg','IMAGES/menubarroll_5.jpg','IMAGES/menubarroll_6.jpg','IMAGES/menubarroll _7.jpg')">
    <table width="800" height="1293" border="0" align="center">
      <tr>
        <td height="1289" valign="top" background="IMAGES/contactmain.jpg" bgcolor="#E8E8E8"><p><img src="IMAGES/header.jpg" width="800" height="365"><br>
          <img src="IMAGES/menubar_1.jpg" width="64" height="50"><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_Home','','IMAGES/menubarroll_2.jpg',1)"><img src="IMAGES/menubar_2.jpg" name="Menu_Home" width="105" height="50" border="0"></a><a href="about.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_About','','IMAGES/menubarroll_3.jpg',1)"><img src="IMAGES/menubar_3.jpg" name="Menu_About" width="104" height="50" border="0"></a><a href="media.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_Media','','IMAGES/menubarroll_4.jpg',1)"><img src="IMAGES/menubar_4.jpg" name="Menu_Media" width="105" height="50" border="0"></a><a href="schedule.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_Schedule','','IMAGES/menubarroll_5.jpg',1)"><img src="IMAGES/menubar_5.jpg" name="Menu_Schedule" width="140" height="50" border="0"></a><a href="contact.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_Contact','','IMAGES/menubarroll_6.jpg',1)"><img src="IMAGES/menubar_6.jpg" name="Menu_Contact" width="126" height="50" border="0"></a><a href="store.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Menu_Store','','IMAGES/menubarroll_7.jpg',1)"><img src="IMAGES/menubar_7.jpg" name="Menu_Store" width="86" height="50" border="0"></a><img src="IMAGES/menubar_8.jpg" width="68" height="50"><br>
        </p>
          <p> </p>
          <p> </p>
          <p> </p>
          <p><br>
            <br>
            <br>
          </p>
          <table width="85%"  border="0">
            <tr>
              <td width="676" align="right" valign="top"><div align="right">
                <p><br>
                </p>
                <form action="process.php" method="post" enctype="multipart/form-data" name="" id="">
                  <p>
                    <input name='Name' type=text class="style1" id="Name" size="30">
                    <br>
                    <br>
    </p>
                  <p>
                    <input name='Email' type=text class="style1" id="Email" size="30">
                  </p><p align="right"><br>
                    <br>
                    <textarea name="Comments" cols="28" rows="8" class="style1" id="Comments"></textarea>
                      <br>
                      <br>
                      <br>
                  </p>
                  <p>                  <input name='Location' type=text class="style1" id="Location" size="30">
                  </p>
                  <p>                  <input type=submit class="style5" value='Submit Form'>
                    </p>
                </form>
                </div></td>
            </tr>
          </table>     
          <br>
          <p> </p>
        </td>
      </tr>
    </table>
    </body>
    </html>

    I'm afraid that it's never going to work. What you're attempting is akin to nailing jelly to a wall.
    Just focus on creating a simple functional form and style it with CSS.
    Other comments:
    Do you realize that you're doing the website a disservice by making all the text of the website part of a huge (300KB+) JPG?
    The top photo with the people looks great but the entire website will be slow and invisible to search engines due to the background JPG e.g. there's no text content on the pages.
    I understand the intent of the design in trying to convey Celtic colours and fonts but it's not the best approach for a website which Google can see and potential visitors can find online. In addition, it's inaccessible to vision impaired users who cannot change colours or resize text due to the JPG and maintenance will be tough since you have to recreate the images every time.
    Use a DW template, keep the colour theme and group photo, drop the background JPG with embedded Celtic font and use CSS-styled text wherever possible.

  • How to copy a folder from TFS source control to Shared location with Powershell script

    Hi,
    I'm looking for a Powershell script where i could copy a folder from TFS Source control to a shared location.
    Details:
    $TeamProject/FolderA - here i want to move FolderA to a shared location called \\Share
    Tried with xcopy: xcopy "$TeamProject/FolderA" "\\Share" ( but no luck, later i found it's only possible to copy files from local to share or share to share location, not from server path to shared location.
    Can someone help me with the power-shell script to achieve above scenario.
    Thanks, BHSR

    Hope the below script works for your scenario. Got the code from http://stackoverflow.com/questions/23739499/copy-files-from-tfs-versioncontrol-to-directory-with-powershell
    $AutoDeployDir = "$\TeamProject/FolderA"
    $deployDirectory = "\\SERVER\SHAREFOLDER\"
    # Add TFS 2013 dlls so we can download some files
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
    $tfsCollectionUrl = "http://CDTFSSERVER:8080/tfs/ProjectCollection"
    $tfsCollection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $tfsCollectionUrl
    $tfsVersionControl = $tfsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    # Register PowerShell commands
    Add-PSSnapin Microsoft.TeamFoundation.PowerShell
    # Get all directories and files in the AutoDeploy directory
    $items = Get-TfsChildItem $AutoDeployDir -Recurse -Server $tfsCollection
    # Download each item to a specific destination
    foreach ($item in $items) {
    # Serverpath of the item
    Write-Host "TFS item to download:" $($item.ServerItem) -ForegroundColor Blue
    $destinationPath = $item.ServerItem.Replace($AutoDeployDir, $deployDirectory)
    Write-Host "Download to" $([IO.Path]::GetFullPath($destinationPath)) -ForegroundColor Blue
    if ($item.ItemType -eq "Folder") {
    New-Item $([IO.Path]::GetFullPath($destinationPath)) -ItemType Directory -Force
    else {
    # Download the file (not folder) to destination directory
    $tfsVersionControl.DownloadFile($item.ServerItem, $([IO.Path]::GetFullPath($destinationPath)))
    Regards, Bharath
    LinkedIn:

  • Change location with credit balance

    I recently moved to the UK from NZ and updated my i-phone system to ios6. Due to this I now need to change my location to the UK so that I can purchase items from the app store. My problem is that I can't change the location because I have a cridit balance of $21. How can i change my location so that i can make purchases. I don't eve care about the credit balance?

    Click here and request assistance.
    (74878)

  • Change password with apple script

    HI there,
    i'm using the do shell script "dscl . -passwd /Users/my username 1"
    it runs without problems but its not changing the password.
    please advise,
    Rafi.

    You are using "-test" instead of "-passwd" for starters
    then you have a space in the username:
    do shell script "dscl . -test /Users/ rafi test 123"
    should be
    do shell script "dscl . -password /Users/rafi test 123"
    I am not an expert in dscl, but the best way for you to test whether do shell script is going to work is to run it in Terminal first.

  • Cannot change location with my iPod Touch - always Brussels!

    I live in Belgium and set my iPod Touch for Brussels time zone. Great, but yesterday I arrived in JAPAN and even though I try to set the general "Date and Time" for Tokyo, the clocks all show the time for Bruxelles-- that is when I look at international time clocks, it shows the time I've set for TOKYO as the time for Bruxelles (Brussels) -- so when I set the time for 3pm in Tokyo then look at the international clock it says TOKYO is 8 hours later, 11:00 pm -- i.e. iPod Touch thinks I'm still in Brussels--
    ---when I go back to General settings time and date, yup, it is back to Brussels--
    I even did a reset (not total, just basic settings) and NO CHANGE I can't get the iTouch to set the current date and time for TOKYO.
    Why not? Is the January program download causing a problem? I wouldn't think so, but...
    (I have been using the new programs since the day they were offered)
    Any comments appreciated-- I travel lots and love the international clocks-- but I need them to be correct! Can't be a Brussels only iTouch!
    Thanks, Steve Tuesday 12 February 2008 (Tokyo)!

    I live in Belgium and set my iPod Touch for Brussels time zone. Great, but yesterday I arrived in JAPAN and even though I try to set the general "Date and Time" for Tokyo, the clocks all show the time for Bruxelles-- that is when I look at international time clocks, it shows the time I've set for TOKYO as the time for Bruxelles (Brussels) -- so when I set the time for 3pm in Tokyo then look at the international clock it says TOKYO is 8 hours later, 11:00 pm -- i.e. iPod Touch thinks I'm still in Brussels--
    when I go back to General settings time and date, yup, *it is back to Brussels*
    I even did a reset (not total, just basic settings) and NO CHANGE I can't get the iTouch to set the current date and time for TOKYO.
    Why not? Is the January program download causing a problem? I wouldn't think so, but...
    (I have been using the new programs since the day they were offered)
    Any comments appreciated-- I travel lots and love the international clocks-- but I need them to be correct! Can't be a Brussels only iTouch!
    OK I solved this by using iTunes with my Mac to update the iTouch-- but what if I don't have my MAC on a trip? How to update the iPod and get the new destination to STICK?
    Regards,
    Steve
    Tuesday 12 February 2008

  • IPad 2 suddenly showing "no service" but seems to be working fine otherwise. Any need for concern? Hard close didn't help. Changing locations with different wi if servers didn't help.

    iPad 2 suddenly showing "no service" but seems to be working fine otherwise. Any cause for concern? Time to get a new iPad?

    It is not picking up the wifi - though it says it is connected . All other devices are connecting fine to the same network

  • Changing SPRM 0 with a script ?

    Hi list,
    In have searched the archives but I did not found an answer or solution: Is there any way you can change SPRM 0 (menue language) with a script ???
    Any help would be great, Michael

    Hi Chris,
    let me first distinguish between a normal menue and a "language menue" which is a menue that is automatically created when you add a second language to the project. Lets say we have got English an Spanish as languages - so in the menue tab you have the option to choose between english and spanish. Now in the scripts I find no way to adress a menue according to it´s language. I can adress the main menue - but wether in english or spanish is no available option. Only choice would be to build a completly seperat menue called "main menue spanish" - okay, I could do that - but what reason is left there for the "language menues" - as nobody sets the DVD player correctly anyway?
    But maybe I miss the point - you say "select the correct language based on the users previous selection" - how exactly would you do that? I have stored the users choice in GRPM 0 (eng=0, span=1) and it does change the audiostream and subtitels like expected - how do I change the language ??
    michael

  • WLC: Need to change pre-shared key with a script

    Hello,
    I need to change pre-shared key on a Guest Wi-Fi with a script.
    Does anybody has an idea how to find the right entry in the WLC 2125 MIB to change it through SNMP?
    Gorazd

    Hi,
    That is a textFramePreferences property
    mySelection.textFramePreferences.verticalThreshold = Number (range 0- 8640)
    ID Object Reference says:
    "...The maximum amount of vertical space between two paragraphs. Note: Valid only when vertical justification is justified; the specified amount is applied in addition to the space before or space after values defined for the paragraph..."

  • Creating \ Changing Functional Location With Contact Person.

    Hello.
    I'm looking for BAPI / Function for creating/changing "Functional Location" with Adding, deleteing OR changing "Contact Person"
    I Have found the BAPI's : BAPI_FUNCLOC_CHANGE
                                         BAPI_FUNCLOC_CREATE
    but thier is no option to handle with "contact person" .
    (SAP Table "IHPA").
    Best Regards'
    Haim B.

    Hello,
    Instead of searching for any FM or anything. Go and create a flow thorugh LSMW and change the desired contact person through it..
    I assure you this is the best and most efficient way.
    first run LSMW and create a flow by changing the contact person of any one functional location and then assign the flow of that lSWM through external notepad file.
    Get in the notepad all the desired FL you want to change run that within minutes your job will be done.

  • Changing cache location with notepad.

    Hey guys, A while ago, before the option to change your cache location was removed from the PC application, I had set it to a secondary HDD on my PC; seeing as how I have an SSD as my primary drive, and like to limit needless write cycles to extend it's life. Now, I remember whenever the option was taken away; and read somewhere that you can go into the core Spotify files with notepad and manually change the location that Spotify stores this information. Being an old install that had just been updated, I checked the file; and it was already set to my desired location. (I guess the settings just carried over.) Fast forward to this weekend, my failing SSD finally got replaced after a long service life; and I decided to start over with a fresh Windows install. I've tried to dig up the post that explained which file to go to in order to change location of my cache, but I can't seem to find it. I was hoping that somebody knew something about it and was able to drop me a hint as to where to go! Thanks, Andy

    Hi ,
    Inside the spotify installation folder (Usually located under C:\Users\YOURUSERNAME\AppData\Roaming\Spotify), there is a file called 'prefs'. Open it with a text editor like Notepad++ (or any other one). You used to be able to find it there. The storage.location line might only be available in older versions though. 
    Aside from that, its on the list of being implemented as a menu option again.

  • Change Page size with a Script

    I have made artwork in Illustrator that is set up as two page spreads on 1 artboard.
    I need to convert this to single page spreads.
    I.e. So for half the documents, I need to set the anchor point of the document to top left and half the width of the artboard.
    For the other half of the documents, I need to set anchor point to to right and half the width.
    Is this possible with scripting?
    I have look around online to find ways of accessing the document size and anchor point via scripting, but cannot seem to find any resources.
    Thanks for any help that can be offered.
    Edit: Also is it possible to create a new artboard with a script and assign it a name?

    here you go, this script splits the artboard in two
    // carlos canto
    // http://forums.adobe.com/message/5380624#5380624
    var idoc = app.activeDocument;
    var ab = idoc.artboards[0];
    var abBounds = ab.artboardRect;// left, top, right, bottom
    var ableft = abBounds[0]; // 0
    var abtop = abBounds[1]; // 612
    var abright = abBounds[2];
    var abbottom = abBounds[3];
    var abwidth = abright - ableft; // 792 // width
    var abheight = abtop- abbottom; // 0 // height
    var half = ableft + abwidth/2;
    var abright2 = half;
    ab.artboardRect = [ableft, abtop, abright2, abbottom];
    var ableft2 = half;
    var newAB = idoc.artboards.add([ableft2, abtop, abright, abbottom]);

  • How do I set up different network locations with different wifi?

    I am having an issue setting up different network locations with different wifi profiles on each. I want to do this to enable fast switching of wireless networks. In my house I have two wireless networks, my own personal one and one that is created by using a wifi modem supplied by my company. If I use the company wifi network then I can get into all my work applications without having to enable VPN access separately. It is also faster. However, they also block many applications including sending email from my personal email account, dropbox, etc. So throughout the day I need to switch wireless networks back and forth.
    I was looking for a faster way to switch and thought I would try network locations. Was able to set up a new network location without issue. However it seems that whatever wireless preferences, changes, or wifi network order I put into my "Work" location it carries over to my other location which is the standard "Automatic".
    What I would like it to have my "Work" location only to be able to connect to my work wifi and my other network (Automatic) to just connect to my home wifi only. That way I can enable faster wifi switching and can even use my launcher program (Alfred) to provide shortcuts.
    Anyway to do this?
    Thanks in advance for any help or advice.

    Just thought I would bump this up in the conversation. Doing a further search I came across this discussion which is similar: Connecting to a wireless network via applescript?
    However, I tried to build the Automator application as discussed and cannot get it to work. Very much a novice at Applescript and Shell Script but have created customized Automator services before. All I get now is "Shell Script command encountered an error". No more detail. I copied and pasted the script as shown in the email thread. Is there any other line or command I need to place in front of it?
    Thanks again for any help

  • Dynamically Changing Location Attributes

    Hi All,
    Has anyone ever successfully set up a BefConsolidate event script with a dynamically changing location attribute. The FDM Admin manual says you can do this:
    RES.PblnValEntGroupOverride=True
    RES.PstrValEntGroup=”MyNewEntityGroup”
    It does not work for me when I sub in a new Validation Entity Group. Has anyone had luck with this? See my actual code below. The new validation group name is 281.
    Sub BefConsolidate(strLoc, strCat, strPer, strTCat, strTPer, strEntGroup)
    RES.PblnValEntGroupOverride=True
    RES.PstrValEntGroup="281"
    End Sub
    Thx,
    Mike

    Hello,
    Yes I am able to write to file before end if.  I also took out end if statement which to me would me FDM would fire the event for all locations without restriction.
    I have not tried the same code in other event script.  Would that work?  The RES statement specifically relates to a consolidation trigger.  I can try another event to see.
    Thanks.

  • Show files with apple script

    what is the comand for showing hidden files in applescipt?
    mac book black   Mac OS X (10.4.8)  

    To display an item inside an invisible folder, you can use a script such as:
    tell application "Finder"
    reveal alias "Macintosh HD:usr:share:"
    end tell
    To set the Finder to display all invisible files:
    tell application "Finder" to quit
    do shell script "defaults write com.apple.Finder AppleShowAllFiles 1" delay 2
    tell application "Finder" to run
    If you run the first script, the folder will disappear in the Finder after the window is closed or its location is changed. The second script can be turned off by replacing the 1 with a 0.
    (18203)

Maybe you are looking for

  • IPod is not recognized in my computer

    One day my iPod worked just fine on my PC, then the next day it stopped being recognized. My iPhone works just fine. I've tried different USB ports and different Apple cables. My iPod works on my GF's laptop. I tired every suggestion in Apple Support

  • Help for a begginer using swing

    Basically I need help with a program for a school project. i am not looking for a quick answer but rather some pointers in the right direction. This is my first time using swing and my first project is to create a blackJack game. I am having trouble

  • Thumbnails in PSE9 organiser on Mac

    The thumbnails in organiser appear as egg timers when there is more than one on view. When the thumbnails first appear there is a message "generating thumbnails" at the bottom of the organiser window. Enlarging the thumbnail to one per page, slider t

  • Organization View for Succesion Planning-My Org. Units!

    Hi, We are in process of implementing Nakisa (Release: 301_701) with EHP4 for few components including Succession Planning. We have completed Admin settings for Succession Planning. When we log in to End User section for succession planning & go to M

  • Usermapping problem with federated portals

    HI experts, We r implimenting FPN functionality for SEM (BI- Integrated Planning) . We have installed portal server for Federated portal .After installation we have set the ticket evaluation parameter in service provider in Visual admin .. we have re