Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a test.tcl (has all permissions) which contains the following-

puts "hello, world"

This is how I'm executing my tcl script-

sudo source /opt/test.tcl

I got the output-

sudo: source: command not found

But I checked the availability of source and sudo using whereis command and they were available-

$ whereis sudo
sudo: /usr/bin/sudo /usr/share/man/man8/sudo.8.gz
$ whereis source
source: /usr/share/man/man1/source.1.gz

However, when I attempt to execute tcl as-

sudo tclsh /opt/test.tcl

I get the expected output-

hello, world

Am I missing something here?

share|improve this question
up vote 1 down vote accepted

source is a shell builtin. Your shell cannot find source for the same reason it can't find cd when you're using sudo - it is not a command. You can use the shell builtin type to check this yourself.

source executes the content of a file you specify in your current shell. That should be fine as long as you don't need an interactive shell, and that your current shell is tclsh. Read here for more information.

sudo tclsh /opt/test.tcl

will work, but it will run in a non-interactive shell.

If you do need to source the script for some reason, decide whether you need to do special permissions or not. If you must, you can su to root and source the script from there.

Also, the output you got for $ whereis source

source: /usr/share/man/man1/source.1.gz

seems to be a man page. So that probably wasn't going to be much use!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .