% osascript scriptname.scpt
Tuesday, November 4, 2014
Running AppleScript from CLI
It is actually pretty simple to run AppleScript from CLI.
Thursday, May 29, 2014
TCL and Expect Library
Source: http://www.tcl.tk/man/tcl8.5/tutorial/Tcl31.html
WORK IN PROGRESS
WORK IN PROGRESS
Preamble
Well, today I have to write an "expect" script to automate some of the lab work that I need to do. I already have basic library like the login procedure and etc done on a previous project. Currently, I have that in a file and usually just "source ..." them in. But why get stuck using just "source ...". Its easy, but I don't think it is cool. LOL. Let's try to look at some of the alternatives.
The following is a direct quote from Tcl31.html's tutorial. The exact URL locates on the top of the page.
Using packages
The
package
command provides the ability to use a package, compare package versions, and to register your own packages with an interpreter. A package is loaded by using the package require
command and providing the package name
and optionally a version
number. The first time a script requires a package Tcl builds up a database of available packages and versions. It does this by searching for package index files in all of the directories listed in the tcl_pkgPath
and auto_path
global variables, as well as any subdirectories of those directories. Each package provides a file called pkgIndex.tcl
that tells Tcl the names and versions of any packages in that directory, and how to load them if they are needed.
It is good style to start every script you create with a set of
package require
statements to load any packages required. This serves two purposes: making sure that any missing requirements are identified as soon as possible; and, clearly documenting the dependencies that your code has. Tcl and Tk are both made available as packages and it is a good idea to explicitly require them in your scripts even if they are already loaded as this makes your scripts more portable and documents the version requirements of your script.Friday, May 2, 2014
Running 32-bit software on Ubuntu 14.04LTS 64-bit
May 2nd, 2014 - Writing Android App
I am trying to play with Android SDK. The machine that I'm using is virtual 64-bit Ubuntu 14.04LTS running on top of VBox. The host OS is Apple MacBook Pro 15" 20011 vintage. May be I will get a MacBook Air later on.I follow the instruction from http://developer.android.com to install 64-bit SDK for my ubuntu. The problem is that when I try to start "Eclipse", it complains that it cant find "adb". Which is confusing to me. When looking at "adb" itself, it shows that it is a 32-bit software instead of 64-bit software as the Android SDK is indicated.
To run 32bit executable file in a 64 bit multi-arch Ubuntu system, you have to add i386 architecture and install libc6:i386,libncurses5:i386,libstdc++6:i386 these three library packages.
sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 sudo ./adb
Tuesday, January 28, 2014
Playing with my Juniper's router... PyEz
JUNOS PyEz is easy as pie...
Ok, may be not that easy. But it is doable.I was randomly browsing the net while waiting to upgrade my MX480 to the latest and greatest JUNOS 12.3R5.whatever.... I remember that I still try to learn my rope around Python and one thing leads to another... "PyEZ" on Juniper's techwiki...
I was hoping to just download the module and run off from techwiki, but unfortunately, I need to go to git to get it. Fortunately, the instruction is easy enough to do. Only two commands to install the required modules on my Ubuntu system:
sudo pip install git+https://github.com/Juniper/ncclient.git sudo pip install junos-ezncMy first try was unsuccessful and I got the following messages:
Running setup.py egg_info for package lxml /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.3.0. Building without Cython. ERROR: /bin/sh: 1: xslt-config: not found ** make sure the development packages of libxml2 and libxslt are installed **Not included in the instruction is that I also need to install two additional packages:
- python-dev
- libxslt1-dev
% sudo apt-get install python-dev % sudo apt-get install libxslt1-devAfter I install the two packages, the installation of the pyez was very smooth.
Jeremy's example in the installation page was pretty easy enough for testing. I highly recommend you to just try it in interactive mode like I did...
reia@ubuntu:~$ python Python 2.7.3 (default, Sep 26 2013, 20:03:06) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pprint import pprint >>> from jnpr.junos import Device >>> dev = Device(host='mysun.example.net', user='me', password='more0fme') >>> dev.open() Device(mysun.example.net) >>> pprint( dev.facts ) {'2RE': True, 'HOME': '/var/home/lab', 'RE0': {'last_reboot_reason': 'Router rebooted after a normal shutdown.', 'mastership_state': 'master', 'model': 'RE-S-1800x4', 'status': 'OK', 'up_time': '17 hours, 51 minutes, 36 seconds'}, 'RE1': {'last_reboot_reason': 'Router rebooted after a normal shutdown.', 'mastership_state': 'backup', 'model': 'RE-S-1800x4', 'status': 'OK', 'up_time': '16 hours, 22 minutes, 55 seconds'}, 'domain': None, 'fqdn': 'Sun-re0', 'hostname': 'Sun-re0', 'ifd_style': 'CLASSIC', 'master': 'RE0', 'model': 'MX480', 'personality': 'MX', 'serialnumber': 'JN1XXXXXXXXXX', 'switch_style': 'BRIDGE_DOMAIN', 'version': '12.3R5.7', 'version_RE0': '12.3R5.7', 'version_RE1': '12.3R5.7', 'version_info': junos.version_info(major=(12, 3), type=R, minor=5, build=7)} >>>And I notice that my router has been upgraded. That's it for now.
Tata my friend.
Subscribe to:
Posts (Atom)