Sunday, September 13, 2009

Using Python to control a Scilab instance

This example shows how to start Scilab, pass it a file to execute, and terminate it if necessary. In this example, Scilab is not in the search path, therefore, the full path to Scilab is necessary.
This example only works on Python 2.6 or later.

import subprocess

# write scilab script into a file. 
# this will be executed by Scilab

f = open('C:\\tmp\\scilabTest.sce', 'w')
cmds = """printf('hello!')
x = input("Press return to continue:","string")

# start up Scilab and retain a handle to control and monitor
sciLabProcess = subprocess.Popen(
    '"C:\\Program Files\\scilab-5.1.1\\bin\\WScilex.exe" -f c:\\tmp\\scilabTest.sce ', 
# wait for process to exit, or terminate it
while sciLabProcess.poll() is None:
    print 'still running'
    reply = raw_input("Kill process ? (type yes) ")
    if reply.strip()=='yes':

Using Python to start a process: Notepad as an example

This examples shows how to start a common process in windows while allowing the Python program to continue and, if needed, terminate the process.
import subprocess

notepadProcess = subprocess.Popen("Notepad")
while notepadProcess.poll() is None:
    print 'still running'
    reply = raw_input("Kill process ? (type yes) ")
    print '>>|'+reply.strip()+'|<<'
    if reply.strip()=='yes':
        print "closing process"

Tuesday, January 13, 2009

Basic setup for dedicated service of a Ubuntu box 1) Setup automatic log in: system>administration>login window>enable automatic login ...... see 2) fix issue with secure wireless. Disable nm-applet in sessions manager: preference>sessions>start-up programs>disable network manager. Creat the following script: #!/bin/bash #launch useful stuff for gnome... #first unlock the default keyring... echo /usr/libexec/pam-keyring-tool -u -s #then run nm-applet in the background... nm-applet & Add this script to the start-up programs.

Automatically log into Ubuntu

see Basic steps: 1) system>administration>login window 2) security tab 3) enable automatic login

Monday, January 12, 2009

Accessing the Linux Machine Remotely from a PC

  1. Install putty portable. See
  2. Start putty portable.
  3. Specify linux machine and hit connect.

Ubuntu tightVNC

To setup and use a Ubuntu machine...

  1. Get tightVNC server and client using the Synaptics package manager
  2. From a terminal start the server using "$tightvncserver -nolisten tcp :1" See
  3. To connect, a) For a PC, download and install. Start and connect. Don't foget to specify the full name including the terminal number, e.g. "computer:1" b) For another linux box, from a terminal start the client using $tightvncclient

My favorite server configuration:

$tightvncserver -display 1280x800 -depth 32

Saturday, January 3, 2009

Getting Webware + Apache to work on Ubuntu

Useful Links:

Steps: see

  1. Install Apache 2. The built in package installer will install the cgi-bin directory under usr/lib.
  2. Download and install Webware 1.0
  3. In ../Webware/WebKit/Adapters/wkcgi run make (I use /home/Webware/Webkit/...)
  4. copy wkcgi to usr/lib/cgi-bin/wkcgi.cgi
  5. copy WebKit.cfg to usr/lib/cgi-bin directory
  6. Install webit from webkit directory $python
  7. start apache
  8. start WebKit app server by invoking WebKit/AppServer
  9. test by opening
  10. test by opening

You can stop the server by typing ^Z at the terminal.

Exploring Python Centric Web servers

Useful Links: Useful Texts: General Comments on Python Centric/Compatible Frameworks
  • Webware
  • Xitami
  • Apache
  • Zope
  • Grok