Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a TCL script from shell script?

Tags:

shell

tcl

I am new to TCL scripting and shell scripting. I want to invoke a TCL script from the shell script. I have tried as below.

#!/bin/sh

for i in {1..5}
do
   my_script
   test_script
done

If I run the script, it is throwing error as follows,

./sample.sh: line 5: my_script: command not found
./sample.sh: line 5: test_script: command not found

Can anyone help me out with this ?

Thanks in advance.

like image 897
Dinesh Avatar asked May 11 '13 14:05

Dinesh


2 Answers

If they cannot be found in your $PATH you have to provide a path to your scripts, e.g.:

./my_myscript         # current directory
/path/to/test_script  # absolute path
like image 132
Adrian Frühwirth Avatar answered Sep 21 '22 11:09

Adrian Frühwirth


If you haven't made your script executable (with chmod +x) then you need to use:

tclsh my_script.tcl

Or maybe tclsh8.5 /path/to/script.tcl or many variations on that.

If you have made the script executable, check that the directory containing the script is on your PATH (if not, use the full filename of the script or adjust your PATH) and that you've got a suitable #! line. The usual recommended one is:

#!/usr/bin/env tclsh8.5

as that will search your path for the tclsh8.5 executable instead of hard-coding it.

like image 40
Donal Fellows Avatar answered Sep 24 '22 11:09

Donal Fellows