Redian新闻
>
我的alia放在script里为什么不工作?
avatar
我的alia放在script里为什么不工作?# Unix - 噫吁兮,危乎高哉
t*l
1
for example,
alias t `cat /bbs/boards/family/6666
写个script把alias t放进去怎么不工作呢?
说没有这个命令。
avatar
o*z
2
不放在script里能工作吗?

【在 t*******l 的大作中提到】
: for example,
: alias t `cat /bbs/boards/family/6666
: 写个script把alias t放进去怎么不工作呢?
: 说没有这个命令。

avatar
t*l
3
能。

【在 o***z 的大作中提到】
: 不放在script里能工作吗?
avatar
c*y
4
source le 没?

【在 t*******l 的大作中提到】
: for example,
: alias t `cat /bbs/boards/family/6666
: 写个script把alias t放进去怎么不工作呢?
: 说没有这个命令。

avatar
t*l
5
source .cshrc?

【在 c********y 的大作中提到】
: source le 没?
avatar
o*z
6

t后面的最好用''括起来
try this in your tc壳:
echo "alias t 'cat /bbs/boards/family/6666'" > ttt
source ./ttt
t

【在 t*******l 的大作中提到】
: for example,
: alias t `cat /bbs/boards/family/6666
: 写个script把alias t放进去怎么不工作呢?
: 说没有这个命令。

avatar
r*s
7
Let's do a test in explicit shell definition.
[12:04am] tail -n 1 ~/.cshrc
alias prsth 'echo "It Works"'
[12:04am] cat xixi.csh
#!/bin/csh
prsth
[12:04am] ./xixi.csh
It Works
[12:04am] cat xixi.sh
#!/bin/sh
prsth
[12:04am] ./xixi.sh
./xixi.sh: prsth: not found
Isn't it clear now?

【在 t*******l 的大作中提到】
: for example,
: alias t `cat /bbs/boards/family/6666
: 写个script把alias t放进去怎么不工作呢?
: 说没有这个命令。

avatar
t*l
8
最后一句看懂了。。。。
你的command提示伏太长了点。。。
hehe~!
thanks.

【在 r********s 的大作中提到】
: Let's do a test in explicit shell definition.
: [12:04am] tail -n 1 ~/.cshrc
: alias prsth 'echo "It Works"'
: [12:04am] cat xixi.csh
: #!/bin/csh
: prsth
: [12:04am] ./xixi.csh
: It Works
: [12:04am] cat xixi.sh
: #!/bin/sh

avatar
t*l
9
thanks.I will try this and come back to you if anything wrong.:P

【在 o***z 的大作中提到】
:
: t后面的最好用''括起来
: try this in your tc壳:
: echo "alias t 'cat /bbs/boards/family/6666'" > ttt
: source ./ttt
: t

avatar
D*e
10
i told him sh doesn't have alias.

【在 r********s 的大作中提到】
: Let's do a test in explicit shell definition.
: [12:04am] tail -n 1 ~/.cshrc
: alias prsth 'echo "It Works"'
: [12:04am] cat xixi.csh
: #!/bin/csh
: prsth
: [12:04am] ./xixi.csh
: It Works
: [12:04am] cat xixi.sh
: #!/bin/sh

avatar
r*s
11
[6:19pm] echo $SHELL
/bin/tcsh
[6:20pm] alias prsth 'echo "It Works"'
[6:20pm] cat > xixi.csh
#!/bin/csh
prsth
[6:21pm] chmod +x xixi.csh
[6:21pm] ./xixi.csh
prsth: Command not found.
[6:21pm] cat > xixi.csh
#!/bin/csh
alias prsth 'echo "It Works"'
prsth
[6:28pm] ./xixi.csh
It Works
**********
From the above test, we can see this might be the case touchsoul got stuck in.
i.e., even when you are using csh/tcsh, yo

【在 D**e 的大作中提到】
: i told him sh doesn't have alias.
avatar
t*l
12
I put my alias in .cshrc, and write it in my script.
alias read '/bbs/boards/family/display_posts alias dead 'read last_post' ------------this doesn't work
both don't work in my script.

【在 r********s 的大作中提到】
: [6:19pm] echo $SHELL
: /bin/tcsh
: [6:20pm] alias prsth 'echo "It Works"'
: [6:20pm] cat > xixi.csh
: #!/bin/csh
: prsth
: [6:21pm] chmod +x xixi.csh
: [6:21pm] ./xixi.csh
: prsth: Command not found.
: [6:21pm] cat > xixi.csh

avatar
r*s
13
可以在一个alias中引用另一个alias的,我就不贴测试过程了。。:p
所以你那个dead不工作是没有道理的。
你在script第一行加"#!/bin/csh"了马?"#!"告诉系统用紧跟的shell
来执行下面的命令。

【在 t*******l 的大作中提到】
: I put my alias in .cshrc, and write it in my script.
: alias read '/bbs/boards/family/display_posts : alias dead 'read last_post' ------------this doesn't work
: both don't work in my script.

avatar
t*l
14
告诉了.而且第一个alias在script里不工作.说找不到这个命令.
我拭了一千遍了都不工作.气也快气死了!
究竟怎么回事啊!

【在 r********s 的大作中提到】
: 可以在一个alias中引用另一个alias的,我就不贴测试过程了。。:p
: 所以你那个dead不工作是没有道理的。
: 你在script第一行加"#!/bin/csh"了马?"#!"告诉系统用紧跟的shell
: 来执行下面的命令。

avatar
r*s
15
find a local unix expert to help you out. sometimes it's just not
easy to find the trick.
several months ago, I started to use digital unix and found a strange
thing I have never encountered. vi refused to read its resource file,
".exrc". I asked my colleagues and didn't get a clue. then I "man vi".
The following messages suddenly shed a light on my puzzle.
[Tru64 UNIX] Additionally, the editor refuses to read the .exrc file if
its mode grants write permission to anyone other than the owner

【在 t*******l 的大作中提到】
: 告诉了.而且第一个alias在script里不工作.说找不到这个命令.
: 我拭了一千遍了都不工作.气也快气死了!
: 究竟怎么回事啊!

avatar
D*e
16
hahahaha. still not working? is your hair white now?
i remember the other time i was debugging a program. it just refused to
work. eventually i noticed i was modifying one copy of the source and
compiling another copy. stupid me.

doesn't work

【在 t*******l 的大作中提到】
: 告诉了.而且第一个alias在script里不工作.说找不到这个命令.
: 我拭了一千遍了都不工作.气也快气死了!
: 究竟怎么回事啊!

avatar
t*l
17
55555555 !_!
头发倒还没白,我是快疯了...
关键是找不到哪里下手啊.
avatar
o*z
18
pick up a book and do some reading

【在 t*******l 的大作中提到】
: 55555555 !_!
: 头发倒还没白,我是快疯了...
: 关键是找不到哪里下手啊.

avatar
t*l
19
手头没什么书了,
需要买.推荐一本吧

【在 o***z 的大作中提到】
: pick up a book and do some reading
avatar
r*s
20
,苏倍庆著,学苑出版社。台湾人写的,深入浅出。

【在 t*******l 的大作中提到】
: 手头没什么书了,
: 需要买.推荐一本吧

avatar
t*l
21
有电子版可以下吗?
avatar
c*e
22
alias 只能在当前 shell 工作。而你的script运行在子 shell 里。所以不工作

work
in.
.cshrc

【在 t*******l 的大作中提到】
: I put my alias in .cshrc, and write it in my script.
: alias read '/bbs/boards/family/display_posts : alias dead 'read last_post' ------------this doesn't work
: both don't work in my script.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。