0
votes

My Python Script on Freebsd 9.2 is throwing error, while it worked fine on Freebsd8.2.

test.py

import os
import subprocess
tclsh = '/usr/local/bin/tclsh'
process = subprocess.Popen([tclsh, 'run_tests.tcl'] )

test.tcl

proc sleep {N} {
    after [expr {int($N * 1000)}]
}

puts "--- Initializing----"

Throws the error

File "run_tests.tcl", line 1
    proc sleep {N} {
         ^
SyntaxError: invalid syntax

So if I change the python script

-tclsh1 = '/usr/local/bin/tclsh'
+tclsh1 = '/usr/local/bin/tclsh8.5'

It works fine on Freebsd9.2.

However, if I execute command on command line it works fine too.

/usr/local/bin/tclsh  test.tcl

Error is thrown while running the command via python script on Freebsd 9.2 with tclsh1 = '/usr/local/bin/tclsh'

Does anyone know whats wrong here?

1

1 Answers

2
votes

Thant's a python syntax error:

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:38) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> proc sleep {n} {
  File "<stdin>", line 1
    proc sleep {n} {
             ^
SyntaxError: invalid syntax

Are you sure /usr/local/bin/tclsh is a Tcl interpreter?

This line looks funny:

process = subprocess.Popen(['tclsh1', 'test.tcl'], bufsize=1, stdout=stdout, cwd=cwd)

If tclsh1 is a variable, why is it quoted?