我的系统没有出现同样的错误。
<>UPDATE>: 关于我最好的猜测,见最后两段。
我最初最好的猜测是,你可以通过改变牧羊来解决这个问题。
#!/bin/tcsh
纽约总部
#!/bin/tcsh -f
(单位:千美元)
#!/bin/csh -f
The features that tcsh adds 纽约总部 the original csh are mostly useful for interactive use rather than scripting.)
The -f
option tells tcsh not 纽约总部 process your .login
and .cshrc
or .tcshrc
files when it starts up. Generally you don t want a script 纽约总部 do this; it makes the script s behavior dependent on your own environment setup. Perhaps you have something in your .login
that does something odd with setenv
, though I can t think of what it might be. Try adding the -f
and see if that helps. Even if it doesn t, you should do that anyway.
(-f
for /bin/sh
or /bin/bash
scripts; 这意味着其他东西,也是需要的。)
其他一些意见:
Setting $PATH
and $LD_LIBRARY_PATH
纽约总部 the empty string is useless. Just delete those two lines.
http://www.un.org。
On re-reading your question, I see what you re doing there. You set $PATH
纽约总部 the empty string, and then prepend more text 纽约总部 it:
setenv PATH ""
setenv PATH this:that:$PATH
That makes more sense than I thought it did, but it s still simpler 纽约总部 write one command:
setenv PATH this:that
Putting .
in your $PATH
, especially at the beginning, is a bad idea. Think about what happens if your run the script in a direc纽约总部ry where someone has deposited a command name ls
that does something nasty. If you want 纽约总部 execute a command in the current direc纽约总部ry, use ./command
. (Putting .
at the end of $PATH
is safer, but still not a very good idea.)
(And using tcsh or csh as a scripting language (as opposed 纽约总部 an interactive shell) is widely considered 纽约总部 be a bad idea as well. This article, even if it doesn t persuade you 纽约总部 give up on tcsh scripting, will at least make you aware of the pitfalls.)
Oh,如果是用纸面书写,那么你为什么把它称作script.sh
? 文档名称上的标记是“不相像的Windows”系统所要求的,但通常需要<代码>。 电话:script.tcsh
,或script.csh
,或仅script/code>。
http://www.un.org。
更仔细地研究一下你重新获得的错误信息,从斜线上看,这种错误来自<代码>/bin/sh,not。
On my system, when I change setenv
纽约总部 Setenv
(a nonexistent command), running the script with tcsh gives me:
Setenv: Command not found.
Setenv: Command not found.
Setenv: Command not found.
Setenv: Command not found.
这与你向我们发出的错误信息相吻合。 当我称之为<代码>/bin/sh foo.tcsh时。 (仅凭<代码>setenv的指挥),我收到:
foo.tcsh: 3: setenv: not found
foo.tcsh: 4: setenv: not found
foo.tcsh: 6: setenv: not found
foo.tcsh: 7: setenv: not found
这与你所发现的错误形式相符。
您说,<代码>/bin/tcsh -version提供了正确结果,从而避免了问题。 有些文字是通过<代码>/bin/sh而不是通过斜体执行。
Here s my best guess about what s going on. You re running on Cygwin, or maybe MSYS, but you re invoking your script from a cmd
shell, not from a Cygwin shell. Your Windows system has been configured 纽约总部 recognize a .sh
suffix 纽约总部 indicate that the file is a script 纽约总部 be executed by C:cygwininsh.exe
(as I mentioned before, file suffixes don t usually matter on Unix, or in the Cygwin environment, but they do on Windows).
The simplest solution would probably be 纽约总部 rewrite the script 纽约总部 conform 纽约总部 Bourne shell syntax. But there should be ways 纽约总部 cause Windows 纽约总部 invoke Cygwin s tcsh
纽约总部 execute it. If I ve guess right, let us know and we can probably come up with a solution.