Category Archives: Mac OS X

Configure BT Echolife/Huawai HG612 as ADSL modem only device

Quite a lot of information on this little, but rather useful device (which in fact is a VDSL/ADSL modem router) can be found at kitz.co.uk, but a step by step guide of how to use this device as a ADSL modem only is not easy to find, so I decided to put my adventures in writing.

First thing first – to get a hold on a device like this you have to visit eBay, as these are made for BT and are the cheapest possible option to get a hold on a device capable of being VDSL/ADSL modem, compared to NETGEAR DM200 with its bad reputation or the pricey DrayTek Vigor 130.

What basically has to happen is to set the WAN interface of the device in bridging mode, so it just passes on the frames to your cable router. The device is by default configured to be a VDSL bridge for the BT network in UK, so it has to be unlocked first, which is a fairly easy procedure, which I have only performed with HG612 type 3B device.

Navigate to https://mega.co.nz/#F!LdJFDIJL!e_E1twsIg2kTet8mPjrb4w and go to B030SP08 folder, where you will need to download the firmware. The file you would most likely want is called bcm96368MVWG_fs_kernel_HG612V100R001C01B030SP08_webgui, which you could probably guess by the name has the web GUI, unless you would like to try the hard way of course…

When ready, do the following:

Configure your computer’s Ethernet port with the IP address 192.168.1.2 and subnet mask 255.255.255.0

With the HG612 powered off, connect a cable between the LAN2 port (you may need to remove the “not in use” sticker) and the Ethernet port on your computer.

Hold down the reset button on the back of the HG612 whilst inserting the power cable. Keep the reset button held for about 5–10 seconds after powering up, then release.

After about 10 seconds you should be able to access the HG612’s “Update Software” web page at the address http://192.168.1.1

Follow the on-screen instructions to upload the latest firmware, you will be notified the process will take 2 minutes – please be patient, give it 3 minutes, go to the toilet, make yourself a coffee, but do not interrupt or power off.

When this is done navigate again to http://192.168.1.1 and you should be greeted by the login page, use default username and password which are both “admin”. Navigate to BASIC -> DSL, tick ALL and then Submit.

 

 

Next step is important, configuring the ATM interface. It has to be configured as Ethernet over ATM type so it can translate the PPPoA frames to PPPoE and pass it on to your cable router to do the authentication, this is a handy function you won’t easily find on many devices, especially cheap once. More about the technology behind can be found at https://en.wikipedia.org/wiki/Point-to-Point_Protocol_over_Ethernet#PPPoEoE-to-PPPoA_converting_modem

Navigate to BASIC -> ATM and choose these options: for the virtual identifiers use 0/38, these are for UK, if it happens so you are somewhere else round the globe check these with your ISP. Leave DSL latency as it is – Path1. For the DSL link type pick the correct one, EoA, this is kind of important. Encapsulation mode – pick VCMUX, again check with your ISP if not sure or see what it is on the router you are supplied, if available. Service type is UBR without PCR. When ready press Submit.

 

 

We are almost ready… Now we have to assign the ATM interface to be the WAN interface. You have few things to do before that though, as by default the device is set to be a VDSL modem, not a ADSL. You have to either remove the PTM interface from the WAN setup, or disable it. In my case I just disabled it, thinking it might one day save me a few clicks.

Go to BASIC -> WAN and select the PTM interface, there untick the WAN connection option and also untick the Port binding LAN1. Click submit when ready.

 

 

Now while you are still there click on the New tab so you can assign the ATM to WAN. From the Layer 2 interface drop-down menu pick atm1/(0_0_38), thick WAN connection so it enables the interface on the WAN, Service list live as it is – INTERNET, Port binding – tick LAN1, this will be the port you connect to your cable router, LAN2 will remain the port you can connect to HG612 if you want to do some configuration changes in the future. For Connection mode select Bridge. And final, but important bit, set Bridge type as PPPoE_Bridged. Click Submit button.

 

 

And this is it! You have a pure ADSL modem only device which passes the WAN IP to the WAN port on your cable router as nature intended! 🙂

On your cable router under the WAN interface configuration choose Connection type PPPoE, add your username and password and you should be good to go, enjoy!


Install Windows 10 64 bit on iMac 7.1 Early 2007 or how to make your old Mac usefull again

As title says it I was given the task to resurrect an iMac and put it back in business! 🙂
Unlike Microsoft, Apple are very picky on how you gonna use your computer and are unpleasantly pushy on dragging you to buy more of their stuff. Simply said as some of you may already know you can not use old, but quite descent hardware wise Mac with Apple’s latest OS due to firmware restrictions. Luckily you can still make some use of it with Windows or Linux.
The iMac in question had a faulty hard drive, which luckily was not too difficult to replace. But as usual the troubles came soon after! 🙂
With a freshly burned DVD with Windows 10 x64 a thought I will be quickly in the game, but NO – got stuck with a black screen and a message to pick the boot type and irresponsive keyboard! It turns out though the computer is 64 bit architecture its EFI is 32 bit and you have no chance to boot it from Windows 10 installation media…
Thanks to good and clever people online help is available! I read this post, downloaded the exe file provided and it all went well!
As the steps I took are slightly different I wanted to have a note of it.
First of course you will need the Windows 10 x64 image file, which you can download from Microsoft. Under Windows 10 with right click on the file select “Mount”.
Just to make life organised create a folder with a name of your choice, in my case it was “NewISO”.
Run Command Prompt as administrator and navigate to where you have the OSCDIMG.EXE file saved /or just type the full path to it/.
Then run the command:
oscdimg -n -m -bf:\boot\etfsboot.com f:\ c:\NewISO\win10_efi32.iso
where f is the drive letter where the image file is mounted.
After this you will have e 64 bit Windows 10 image file with 32 bit EFI, do not worry about the warning message related to NT 3.5, just burn it on DVD or USB stick and use it.
Final words – I do not quite know how this program, which is a Microsoft genuine tool, manages to change the boot loader. I would advice you to download it from the post link above or at least make sure you use the same version, which is 2.54, as this may have something to do with the success of the procedure and a newer one may just put back 64 bit EFI again. I will be glad if someone more knowledgeable explains it in detail.

Applescript Apps fail to launch after upgrade to macOS Sierra and High Sierra – workaround

If you recently upgraded your Apple Mac to the latest Sierra versions of the OS you might be from the unlucky once with Applescript applications which does not launch anymore. And if you tried without joy any of this:

  • saving the apps in the Application folder;
  • manually creating executable applet within the Applescript app;
  • disabling SIP;
  • disabling Gatekeeper /GUI or via Terminal/;
  • signed the app with developer ID;

PANIC NOT! 🙂 There is still hope, thanks to the good old Terminal, bash shell and the handy command osascript!

Basically the idea is this, with the osascript command you are able to run a Applescript without triggering the launch of Script Editor, so if you type in Terminal

osascript /path/to/script/YourScript.scpt

the script will be executed nicely and without a hassle.

But what if you happen to have just the Applescript app, not the code of the script itself? Luckily osascript command can handle this as well! You simply have to dig a bit in to the app and point to the compiled script in it, something like this:

osascript /path/to/Applescript.app/Contents/Resources/Scripts/main.scpt

Luckily in Sierra this bypasses all the clutches the OS offers. 🙂

This can be used in a bash script for convenience, something like that as an example:

#!/bin/bash

osascript /path/to/Applescript.app/Contents/Resources/Scripts/main.scpt && trap ‘/usr/bin/osascript -e “tell application \”terminal\” to quit”‘ 0

I think that’s pretty much it, hope you will find it helpful.


XtraFinder error message “XtraFinder Beta has expired!” fix with applescript

I was recently asked to help with the annoying XtraFinder’s message “XtraFinder Beta has expired!” and make it disappear without user input. As what was suggested in the official support page did not work I went to see what is available online, Google is your friend, right!? 🙂

Well unfortunately I found only one good and interesting blog post on the subject involving Hopper Disassembler, but that did not worked for me, whatever I tried I did not manage to produce an executable file which will actually work. The tutorial is for XtraFinder version 0.25 where mine was 0.25.8 and though the assembler instructions and the function looked the same I think that matters.

As I am not an assembler guru I went back to the good old applescript to make a few clicks on behalf of a human 🙂 Please check the script below and change it if you need to. The script app has to be in your log in items and will/should work fine even after you upgrade to the latest version of XtraFinder, currently 0.25.9 /which by the way fixes the nag messages, until the time for the next update probably, which if not on time will probably start the receiving of the expire message again.. or may be not… :-)/.

So here we go:

 

delay 3

tell application “XtraFinder” to activate

delay 1

tell application “System Events”

 if exists (window 1 of process “XtraFinder”) then

  tell process “XtraFinder”

   set XfinderMess to the value of static text 1 of window 1 of application process “XtraFinder” of application “System Events”

   if XfinderMess = “System Integrity Protection is enabled.” then

    click button “OK” of window 1 of application process “XtraFinder” of application “System Events”

    delay 10

    tell application “System Events”

     if exists (window 1 of process “Finder”) then

      tell process “Finder”

       set finderMess1 to the value of static text 1 of window 1 of application process “Finder” of application “System Events”

       if finderMess1 = “XtraFinder Beta has expired!” then

        click button “OK” of window 1 of application process “Finder” of application “System Events”

        delay 6

        tell application “System Events”

         if exists (window 1 of process “Finder”) then

          tell process “Finder”

           set finderMess2 to the value of static text 1 of window 1 of application process “Finder” of application “System Events”

           if finderMess2 = “You’re up-to-date!” then

            click button “OK” of window 1 of application process “Finder” of application “System Events”

           end if

          end tell

         else 

          quit

         end if 

        end tell

       end if

      end tell

     else

      quit

     end if

    end tell

   end if

  end tell

 else

  quit

 end if

end tell

 

Enjoy 🙂

 


AppleScript execution depending on system event

Some time ago I had to create a script to execute on startup, do its job and reboot the computer if needed, but how do you prevent going in to rebooting loop? Luckily after a bit of wondering around I managed to find a solution – the system_profiler command! It gives the opportunity to track the hardware state and if there is any change it can be used to trigger a script execution.

I do not know about your experience with Macs and multiple displays, but according to mine it can get messy, especially if you have more then two displays or /god forbid! ;-)/ Apple plus other display manufacturers.

In my case the problem was not having all the displays on after initial boot, the main Philips display comes on, but both Apple Thunderbolt displays did not. After a reboot though everything comes back to normal. The task was to make a script checking the state of the screens and automatically reboot if there is a problem.

So this is the script I have made to solve the problem, you can tweak it the way you want and need /may be if you use it or post it somewhere mentioning me would be nice :-)/:

delay 15
set display to (do shell script “system_profiler SPDisplaysDataType | grep Thunderbolt; echo $?”)
if display = “1” then
    do shell script “open /Path/To/Your/Scripts/Reboot.app”
else
    display notification “No Need to Reboot!”
    delay 5
    quit
end if

Reboot.app is just a script to reboot the computer, you can make your own, use my previous posts or use any other means to achieve the goal.

And finally – if you insist on having your application windows exactly on the screen you want and at the location you want them to be, there is one very good application called Stay, it is not free, but does the job nicely.

Enjoy!


ApleScript examples for Mac OS X El Capitan

Time is tight as usual, so let’s not waste it and get on with the already delayed El Capitan post. 🙂

As some of you already know Apple introduced a new security feature to their latest OS X called System Integrity Protection (SIP). What it basically does is to limit access to sensitive parts of the OS, prevent code injection, etc. This is all fine probably for most users, but limits the possibilities of tweaking the system as well as flexibility of manipulating certain aspects of the OS’s behaviour.

So this brings some inconvenience when you try to automate certain aspects of your daily routine. For example the bless command will not work, you can no longer “empty trash” while a file is still engaged in a process, if disable SIP you can no longer do repair permissions on your system files as this feature has been removed from Disk Utility.

Simply said – if you want the full control over the OS you will have to disable SIP. I am not going in to details on how to do it, there are many articles on internet about that. Here are just few links if you are interested:

Apple’s official article – https://developer.apple.com/library/mac/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html

 

XtraFinder’s article on how to partially disable SIP – https://www.trankynam.com/xtrafinder/sip.html

or this one for some more customisation – https://www.reddit.com/r/osx/comments/3hv3kk/update_on_rootless_the_configuration_mechanism/

 

Below you will find two AppleScripts, one for automating the process of repairing file permissions and the other one is for empting your trash.

First the script which does the permission repair. Before using it you will need to download and install the utility from here https://www.firewolf.science/2015/07/repairpermissions-v2-0-cli/

Make sure you follow the installation guidance, read the notes section – it is kind of important.

Alternatively if you do not want to use this utility you may prefer to do it differently by using repair_packages command following this tutorial: http://lifehacker.com/verify-and-repair-permissions-from-the-command-line-in-1741718667

 

And the script itself, change the necessary bits with your data or change it the way it suits you:

 

display dialog “Repair Disk Permissions” buttons {“VolumeName 1”, “Volume Name 2”, “QUIT”} default button “QUIT”

if button returned of result = “QUIT” then

     quit

else

     set diskVol to the button returned of the result as text

     tell application “Terminal”

          activate

          set RP to do script “sudo /usr/local/bin/RepairPermissions \”/Volumes/” & diskVol & “\” “

          delay 1

          tell application “System Events”

               keystroke “YourPassword” & return

          end tell

          set mainID to id of front window

          close (every window whose id ≠ mainID)

          repeat until busy of RP is false

               delay 1

          end repeat

     end tell

end if

delay 30

tell application “Terminal” to quit

 

The second script for empting the trash looks a bit bloated, but as AppleScript has no understanding of “go to” statement /at least I could not find any referral to it, though for some reason this statement is considered a bad practise/ I had no choice but to leave it as it is. Any suggestions are welcome.

As per my previous post regarding AppleScript you will have to adjust some details in the script:

 

 

do shell script “sudo nvram SystemAudioVolume=%80” password “YourPass” with administrator privileges

do shell script “defaults write com.apple.loginwindow TALLogoutSavesState -bool false” password “YourPass”with administrator privileges

set trashcontents to quoted form of (do shell script “ls ~/.Trash”)

if trashcontents = “” then

     tell application “Finder” to activate

     tell application “System Events”

          tell process “Finder”

               click menu item 13 of menu 1 of menu bar item “Apple” of menu bar 1

          end tell

     end tell

    delay 5

     tell application “System Events”

          tell process “loginwindow”

               activate

               click button 2 of window 1

          end tell

     end tell

else

     do shell script “sudo rm -rf ~/.Trash/*” password “YourPass” with administrator privileges

     delay 10

     tell application “Finder” to activate

     tell application “System Events”

          tell process “Finder”

               click menu item 13 of menu 1 of menu bar item “Apple” of menu bar 1

          end tell

     end tell

     delay 5

     tell application “System Events”

          tell process “loginwindow”

               activate

               click button 2 of window 1

          end tell

     end tell

end if

 

And that’s it for now, hope this helps not just me, but someone else too 🙂

 

 

 


Useful AppleScript examples

Here are some useful /I think/ AppleScript examples which can be used on their own or in other scripts. The presumption here is you already have an idea of how to use the Script Editor. Keep in mind some scripts might not behave as it should depending on your OS X and will need to be slightly adjusted. I will do separate post just for EL CAPITAN when I got some time. 🙂

Ways to open and close applications with apple script:

If you want or need to use the Terminal to open an application:

 

tell application “Terminal”

      do script “open /Applications/Safari.app; exit”

end tell

delay 2

tell application “Terminal” to quit

 

But if you prefer the short way of doing it you can just type

 

do shell script “open /Applications/Safari.app; exit”

 

or

 

tell application “Safari” to activate

 

And to close application few options are as follows

 

tell application “Safari” to quit

 

or

 

do shell script “killall Safari”

 

Closing Finder application will simply reload it, which is sometimes necessary

 

do shell script “killall Finder” password “YourPassword” with administrator privileges

 

Managing optical drives:

When the case is to manage optical drives using applescript my personal opinion is this is best done with the use of drutil command. To find more about the command you can man it and in terminal window you can:

 

$ drutil info

 

As an example to close the tray of optical drive with the name “DVD-RW GH41N” you can:

 

tell application “Terminal”

      do script “drutil tray close -drive ‘DVD-RW GH41N’; exit”

end tell

delay 3

tell application “Terminal” to quit

 

or if it is external one you can just

 

tell application “Terminal”

      do script “drutil tray close -drive external; exit”

end tell

delay 3

tell application “Terminal” to quit

 

To open the tray

 

tell application “Terminal”

      do script “drutil eject -drive ‘DVD-RW GH41N’; exit”

end tell

delay 3

tell application “Terminal” to quit

 

Automating shutdown and restart:

If the case is to shutdown or restart the computer with just a click of a button you can use the scripts below. They will also do some additional tasks like switching off the option of restarting the active application on boot, silence the startup chime, empty the trash can, which you may of course skip.

Reboot using terminal command:

 

do shell script “defaults write com.apple.loginwindow TALLogoutSavesState -bool false” password “YourPassword ” with administrator privileges

delay 2

do shell script “nvram SystemAudioVolume=%80” password “YourPassword ” with administrator privileges

delay 2

do shell script “shutdown -r now” password “YourPassword” with administrator privileges

 

Reboot using Mac OS X menu, mind though menu item 13 in the example might not be correct for you, so adjust it if necessary:

 

do shell script “defaults write com.apple.loginwindow TALLogoutSavesState -bool false” password “YourPassword” with administrator privileges

delay 2

do shell script “sudo nvram SystemAudioVolume=%80” password “YourPassword” with administrator privileges

delay 2

tell application “Finder” to activate

tell application “System Events”

      tell process “Finder”

       click menu item 13 of menu 1 of menu bar item “Apple” of menu bar 1

      end tell

end tell

delay 3

tell application “System Events”

      tell process “loginwindow”

       activate

       click button 2 of window 1

      end tell

end tell

 

To shutdown the computer, following the same order and logic as above use the examples below. Again mind menu item 15, the number might not be the same for you.

 

tell application “Finder”

      empty trash with security

end tell

do shell script “shutdown -h now” password “YourPassword” with administrator privileges

 

or

 

tell application “Finder”

      empty trash with security

end tell

delay 10

tell application “Finder” to activate

tell application “System Events”

      tell process “Finder”

       click menu item 15 of menu 1 of menu bar item “Apple” of menu bar 1

      end tell

end tell

delay 3

tell application “System Events”

      tell process “loginwindow”

       activate

       click checkbox 1 of window 1

       click button 2 of window 1

      end tell

end tell

 

Changing startup disk:

Something else which like me you can find useful is to quickly reboot to another Mac OS X installation. The first script is using script with buttons, which is faster, but Apple decided you do not need more then 3 buttons in a script dialog. So if you are having more than 3 bootable drives /some people do, trust me :-)/ you have to use a script with a list. Reboot.app in the examples is another script to reboot the computer, but you can do it differently.

The example script with the buttons:

 

display dialog “Select a startup disk” buttons {“NameOf HD1”, “NameOf HD2”, “QUIT”} default button “QUIT”

if button returned of result = “QUIT” then

      quit

else

      set bootVol to the button returned of the result as text

      do shell script “bless -mount \”/Volumes/” & bootVol & “\” -setBoot” password “YourPassword” with administrator privileges

      tell application “Reboot.app” to activate

end if

 

And for a list it might be something like this:

 

set Disks to {“1”, “2”, “3”, “4”, “5”}

set selectedDisk to {choose from list Disks with title “Startup Disk” with prompt “Choose Disk” default items “2” without multiple selections allowed and empty selection allowed}

do shell script “bless -mount \”/Volumes/” & selectedDisk & “\” -setBoot” password “YourPassword” with administrator privileges

tell application “Reboot.app” to activate

 

This is just an example script showing how to control an application with System Events, in this case Skype. Here the preferred web cam is picked from the list of available devices.

 

tell application “Skype” to activate

delay 5

tell application “System Events”

      tell process “Skype”

       click menu item 3 of menu 1 of menu bar item “Skype” of menu bar 1

      end tell

end tell

delay 5

tell application “System Events”

      tell process “Skype”

       set winName to the name of window 1

       if winName = “General” then

                   click button “Audio/Video” of toolbar 1 of window 1

                   click pop up button 2 of window 1

                   click menu item “FaceTime HD Camera (Display)” of menu 1 of pop up button 2 of window “Audio/Video”

       else

                   tell application “System Events” to keystroke “w” using command down

       end if

      end tell

end tell

 

That is quite enough for now, future scripts will be in separate posts, hope you found this information useful. Enjoy 🙂