LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 865|回复: 6

我看不太明白这个exec的意思

[复制链接]
发表于 2005-4-30 18:10:57 | 显示全部楼层 |阅读模式
我看不太明白这个exec的意思

我看不太明白这个exec的意思
请版主大哥给我说一说吧~
我知道你的英语好强的!帮我翻译一下吧!
谢谢了~
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process
is created. The arguments become the arguments to command. If
the -l option is supplied, the shell places a dash at the begin-
ning of the zeroth arg passed to command. This is what login(1)
does. The -c option causes command to be executed with an empty
environment. If -a is supplied, the shell passes name as the
zeroth argument to the executed command. If command cannot be
executed for some reason, a non-interactive shell exits, unless
the shell option execfail is enabled, in which case it returns
failure. An interactive shell returns failure if the file can-
not be executed. If command is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.

如果命令是指定的,那么它将代替shell。不创建新的进程。这个命令将变成那个命令。

我想我翻译的不对劲吧! 请大家帮帮忙吧!
发表于 2005-4-30 18:26:43 | 显示全部楼层
如果在exec后指定了命令,就替换当前shell进程,而不开启新的进程.
eg:[php]
#!/bin/bash
echo "This line appears ONCE in the script,yet it keep echoing."
echo "The PID of this instance of the script is still $$."

# Demonstrate that a subshell is not forked off.
echo "==============Hit Ctrl-C to exit================"
sleep 1

exec $0
echo "This line will never echo!"

exit 0
[/php]
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-30 18:41:01 | 显示全部楼层
谢谢版主

你写的东东我放在SHELL下试了
太神奇了  
我应该怎么学习啊   才能了解到shell程序的编写啊

有没有中文的入门教程啊
请给我几个行吗?
谢谢
谢谢版主先生
回复 支持 反对

使用道具 举报

发表于 2005-4-30 18:49:49 | 显示全部楼层
Post by ccic
谢谢版主

你写的东东我放在SHELL下试了
太神奇了  
我应该怎么学习啊   才能了解到shell程序的编写啊

有没有中文的入门教程啊
请给我几个行吗?
谢谢
谢谢版主先生


书籍自己去书店买,怎么学这个问题,因人而异.买本好书,从头看到尾.再从尾看到头 如果不要用,学了也没什么用.
回复 支持 反对

使用道具 举报

发表于 2005-4-30 22:59:39 | 显示全部楼层
楼主是马甲
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-5-1 00:07:56 | 显示全部楼层
楼主是马甲

你在说什么
回复 支持 反对

使用道具 举报

发表于 2005-5-1 00:16:10 | 显示全部楼层
我看不太明白这个exec的意思

我看不太明白这个exec的意思
请版主大哥给我说一说吧~
我知道你的英语好强的!帮我翻译一下吧!
谢谢了~
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process
is created. The arguments become the arguments to command. If
the -l option is supplied, the shell places a dash at the begin-
ning of the zeroth arg passed to command. This is what login(1)
does. The -c option causes command to be executed with an empty
environment. If -a is supplied, the shell passes name as the
zeroth argument to the executed command. If command cannot be
executed for some reason, a non-interactive shell exits, unless
the shell option execfail is enabled, in which case it returns
failure. An interactive shell returns failure if the file can-
not be executed. If command is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.

如果命令是指定的,那么它将代替shell。不创建新的进程。这个命令将变成那个命令。

我想我翻译的不对劲吧! 请大家帮帮忙吧!
from: http://bbs.chinaunix.net/forum/v ... 9155&show_type=

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表