我有一个test.tcl(具有所有权限),其中包含以下内容-
#!/usr/bin/tclsh
puts "hello, world"
这就是我执行tcl脚本的方式-
sudo source /opt/test.tcl
我得到了输出-
sudo: source: command not found
但是我使用whereis
命令检查了源和sudo的可用性,它们是可用的-
$ whereis sudo
sudo: /usr/bin/sudo /usr/share/man/man8/sudo.8.gz
$ whereis source
source: /usr/share/man/man1/source.1.gz
但是,当我尝试以以下方式执行tcl时-
sudo tclsh /opt/test.tcl
我得到了预期的输出-
hello, world
我在这里想念什么吗?
source
是内置的shell。您的shell找不到source
的原因与cd
使用sudo时找不到的原因相同-这不是命令。您可以使用内置的Shell自行type
检查。
source
执行您在当前shell中指定的文件的内容。只要您不需要交互式shell,并且您当前的shell是tclsh,那应该没问题。在这里阅读更多信息。
sudo tclsh /opt/test.tcl
可以使用,但可以在非交互式外壳中运行。
如果source
由于某种原因确实需要脚本,请决定是否需要特殊权限。如果必须的话,您可以从那里启动su
root和source
脚本。
另外,您获得的输出 $ whereis source
source: /usr/share/man/man1/source.1.gz
似乎是man
一页。所以这可能没什么用!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句