2010-07-08 22:03:41 +04:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en" xml:lang = "en" >
< head >
<!--
*
2016-05-06 05:15:13 +03:00
* Copyright 2010-2016, Haiku. All rights reserved.
2010-07-08 22:03:41 +04:00
* Distributed under the terms of the MIT License.
*
* Authors:
* Humdinger < humdingerb @ gmail . com >
* Translators:
* Pengphei Han
*
-->
< meta http-equiv = "content-type" content = "text/html; charset=utf-8" / >
< meta http-equiv = "Content-Style-Type" content = "text/css" / >
< meta name = "robots" content = "all" / >
2010-08-02 20:51:09 +04:00
< title > 命令行程序< / title >
2010-07-08 22:03:41 +04:00
< link rel = "stylesheet" type = "text/css" href = "../../Haiku-doc.css" / >
< / head >
< body >
< div id = "banner" >
2010-08-02 20:51:09 +04:00
< div > < span > 用户指南< / span > < / div >
2010-07-08 22:03:41 +04:00
< / div >
< div class = "nav" >
< div class = "inner" >
< ul class = "lang-menu" >
< li class = "now" > < img src = "../../images/flags/zh_CN.png" alt = "" / > 中文 [中文]< / li >
< li > < a href = "../../fr/applications/cli-apps.html" > < img src = "../../images/flags/fr.png" alt = "" / > Français< / a > < / li >
< li > < a href = "../../de/applications/cli-apps.html" > < img src = "../../images/flags/de.png" alt = "" / > Deutsch< / a > < / li >
< li > < a href = "../../it/applications/cli-apps.html" > < img src = "../../images/flags/it.png" alt = "" / > Italiano< / a > < / li >
< li > < a href = "../../ru/applications/cli-apps.html" > < img src = "../../images/flags/ru.png" alt = "" / > Русский< / a > < / li >
< li > < a href = "../../es/applications/cli-apps.html" > < img src = "../../images/flags/es.png" alt = "" / > Español< / a > < / li >
2011-05-22 22:01:43 +04:00
< li > < a href = "../../sv_SE/applications/cli-apps.html" > < img src = "../../images/flags/sv_SE.png" alt = "" / > Svenska< / a > < / li >
2010-07-08 22:03:41 +04:00
< li > < a href = "../../jp/applications/cli-apps.html" > < img src = "../../images/flags/jp.png" alt = "" / > 日本語< / a > < / li >
< li > < a href = "../../uk/applications/cli-apps.html" > < img src = "../../images/flags/uk.png" alt = "" / > Українська< / a > < / li >
< li > < a href = "../../pt_PT/applications/cli-apps.html" > < img src = "../../images/flags/pt_PT.png" alt = "" / > Português< / a > < / li >
2011-12-04 00:12:53 +04:00
< li > < a href = "../../fi/applications/cli-apps.html" > < img src = "../../images/flags/fi.png" alt = "" / > Suomi< / a > < / li >
< li > < a href = "../../sk/applications/cli-apps.html" > < img src = "../../images/flags/sk.png" alt = "" / > Slovenčina< / a > < / li >
2012-11-16 01:36:54 +04:00
< li > < a href = "../../hu/applications/cli-apps.html" > < img src = "../../images/flags/hu.png" alt = "" / > Magyar< / a > < / li >
< li > < a href = "../../pt_BR/applications/cli-apps.html" > < img src = "../../images/flags/pt_BR.png" alt = "" / > Português (Brazil)< / a > < / li >
2013-02-18 00:51:59 +04:00
< li > < a href = "../../ca/applications/cli-apps.html" > < img src = "../../images/flags/ca.png" alt = "" / > Català< / a > < / li >
2014-05-31 02:02:36 +04:00
< li > < a href = "../../pl/applications/cli-apps.html" > < img src = "../../images/flags/pl.png" alt = "" / > Polski< / a > < / li >
2016-05-06 05:15:13 +03:00
< li > < a href = "../../ro/applications/cli-apps.html" > < img src = "../../images/flags/ro.png" alt = "" / > Română< / a > < / li >
2010-07-08 22:03:41 +04:00
< li > < a href = "../../en/applications/cli-apps.html" > < img src = "../../images/flags/gb.png" alt = "" / > English< / a > < / li >
< / ul >
< span >
2010-12-04 22:04:43 +03:00
« < a href = "list-cli-apps.html" > List of commands< / a >
:: < a href = "../applications.html#cli-apps" class = "uplink" > Applications< / a >
2010-07-08 22:03:41 +04:00
< / span > < / div >
< / div >
< div id = "content" >
< div >
2016-05-06 05:15:13 +03:00
< div class = "box-info" > 本节的翻译还未完成。在未完成之前,所有的未完成部分都将使用英语原文。< / div >
2010-07-08 22:03:41 +04:00
2010-12-30 22:10:45 +03:00
< h2 > < img src = "../../images/apps-images/cli-app-icon_64.png" alt = "cli-app-icon_64.png" width = "64" height = "64" / > Haiku专用命令行程序< / h2 >
2010-07-08 22:03:41 +04:00
< table summary = "layout" border = "0" cellspacing = "0" cellpadding = "2" >
2016-05-06 05:15:13 +03:00
< tr > < td > 位置:< / td > < td style = "width:15px;" > < / td > < td > < span class = "path" > /boot/system/bin/< / span > < br / >
< span class = "path" > /boot/system/non-packaged/bin/< / span > < br / > < span class = "path" > ~/config/bin/< / span > < br / > < span class = "path" > ~/config/non-packaged/bin/< / span > < / td > < / tr >
2010-07-08 22:03:41 +04:00
< / table >
< p > < br / > < / p >
2016-05-06 05:15:13 +03:00
< p > All commandline applications shipped with Haiku are in < span class = "path" > /boot/system/bin/< / span > . Your own or additionally installed commandline apps will appear there as well, or in < span class = "path" > ~/config/bin/< / span > , when installed from a .hpkg package. Otherwise you can put them into < span class = "path" > /boot/system/non-packaged/bin/< / span > or < span class = "path" > ~/config/non-packaged/bin/< / span > . All these locations are part of the PATH variable and are therefore automatically found.< br / >
The following isn't an exhaustive list of all Haiku-specific CLI apps, it serves just to highlight a few of the most useful to give you a taste. Feel encouraged to explore what's in the < span class = "path" > bin/< / span > folders on your own a bit. Executing an app with the parameter < tt > --help< / tt > shows the usage of the command and all its various options.< / p >
2010-07-08 22:03:41 +04:00
< h3 > < a href = "#" > < img src = "../../images/up.png" style = "border:none;float:right" alt = "index" / > < / a >
< a id = "cli-attributes" name = "cli-attributes" > 关于文件属性的命令: < span class = "cli" > listattr< / span > , < span class = "cli" > catattr< / span > , < span class = "cli" > addattr< / span > , < span class = "cli" > rmattr< / span > , < span class = "cli" > copyattr< / span > < / a > < / h3 >
< p > 这些命令用于显示, 读取, 添加和删除文件的属性; 需要注意的是, 这些元数据仅仅可用于BFS格式的磁盘和分区, 而且移动文件到其他的文件系统将会把其相关的属性移除! < br / >
2010-08-02 20:51:09 +04:00
上面的命令在< a href = "../attributes.html#attributes-terminal" > 终端中的属性< / a > 会有相关的描述。< / p >
2010-07-08 22:03:41 +04:00
< h3 > < a href = "#" > < img src = "../../images/up.png" style = "border:none;float:right" alt = "index" / > < / a >
< a id = "cli-index" name = "cli-index" > 关于文件索引的命令:< span class = "cli" > lsindex< / span > , < span class = "cli" > mkindex< / span > , < span class = "cli" > reindex< / span > , < span class = "cli" > rmindex< / span > < / a > < / h3 >
2010-08-02 20:51:09 +04:00
< p > 利用这些命令, 您可以对BFS的索引属性进行排序, 新建, 重新索引和删除等操作。由于每个卷都有自己独立的索引, 所以在不同的卷之间拷贝文件时尤其要注意。< br / > 上述这些命令在< a href = "../index.html" > 索引< / a > 主题中会有详细的描述。< / p >
2010-07-08 22:03:41 +04:00
2016-05-06 05:15:13 +03:00
< h3 > < a href = "#" > < img src = "../../images/up.png" style = "border:none;float:right" alt = "index" / > < / a >
< a id = "cli-pkg" name = "cli-pkg" > Relating to package management: < span class = "cli" > package< / span > , < span class = "cli" > pkgman< / span > < / a > < / h3 >
< p > The < span class = "cli" > package< / span > command is used to manage HPKG packages. Have a look at the article < a href = "https://www.haiku-os.org/guides/daily-tasks/install-applications" > Installing applications< / a > to learn the very basics. Usually the tool < a href = "https://github.com/haikuports/haikuports/wiki" > haikuporter< / a > is used to create so-called recipes for automatic package building.< / p >
< p > < span class = "cli" > pkgman< / span > is used to search, install, update and uninstall packages. Package repositories can be added, dropped and their package lists refreshed. A special kind of update is invoked with the parameter < tt > full-sync< / tt > : It is more aggressive and also downgrades or removes packages, if necessary.< br / >
For more details on a parameter, append "--help", e.g. < tt > pkgman search --help< / tt > .< / p >
2010-07-08 22:03:41 +04:00
< h3 > < a href = "#" > < img src = "../../images/up.png" style = "border:none;float:right" alt = "index" / > < / a >
< a id = "cli-scripting" name = "cli-scripting" > 有用的脚本命令< / a > < / h3 >
2010-07-21 19:52:50 +04:00
< p > 下面是一些非常有用的命令行工具,尤其适用于撰写脚本(详情请参阅 < a href = "../bash-scripting.html" > Bash和脚本< / a > )。< / p >
2010-07-08 22:03:41 +04:00
< table summary = "scripting cli tools" border = "0" cellpadding = "2" cellspacing = "0" >
< tr > < td > < p > < span class = "cli" > alert< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2010-07-21 19:52:50 +04:00
< td valign = "top" > < p > < span class = "cli" > alert< / span > 该命令将会打开一个带有预定义图标, 说明注记和三个按钮的典型警示窗口, 并且在终端中返回已选中按钮的标题和退出状态( 以0开始) 。例如, 下面就是一个例子: < / p >
2010-07-08 22:03:41 +04:00
< pre class = "terminal" > alert --idea "FantasticApp(tm) installed successfully!
Would you like a link to it?" "On Desktop" "In Deskbar" "No thanks"< / pre >
< p > < img src = "../images/apps-images/cli-alert.png" alt = "cli-alert.png" / > < / p >
< / td > < / tr >
< tr > < td > < p > < span class = "cli" > filepanel< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2010-07-21 19:52:50 +04:00
< td valign = "top" > < p > < span class = "cli" > filepanel< / span > 显示一个装载或者保存文件的面板,并且让用户选择相应的文件和位置。同时您将会获取到一个文件或者文件的路径作为返回值。并且还有几个参数可供使用,例如,设置起始目录,窗体的标题,默认保存的文件名。下面是一个例子:< / p >
2010-07-08 22:03:41 +04:00
< pre class = "terminal" > filepanel -s -t "Save your logfile" -d ~/config/settings -n Fantastic.log< / pre >
< p > < img src = "../images/apps-images/cli-filepanel.png" alt = "cli-alert.png" / > < / p >
< / td > < / tr >
2015-01-17 20:26:33 +03:00
< tr > < td > < p > < span class = "cli" > hey< / span > < / p > < / td > < td style = "width:10px;" > < / td >
< td valign = "top" > < p > < span class = "cli" > hey< / span > 是一个小巧的帮助工具,可以发送 BMessages 给应用,并打印出回复结果。它可以用于应用脚本,例如,通过命令行或者脚本 “远程控制” 一个程序。它的使用会有一点复杂。非常感谢 Scot Hacker 的 BeOS 圣经,其中有一个 Chris Herborth 编写的 < a href = "http://www.birdhouse.org/beos/bible/bos/ch_scripting6.html" > hey 入门指南< / a > 。 < / p >
2010-07-08 22:03:41 +04:00
< / td > < / tr >
< tr > < td > < p > < span class = "cli" > query< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2010-07-21 19:52:50 +04:00
< td valign = "top" > < p > < span class = "cli" > query< / span > 是查询面板的命令行版本。实际上,一个创建搜索项目的快速方式是在搜索面板创建一个查询,选择 < span class = "menu" > by formula< / span > ,在查询词的前后添加双引号(< tt > "< / tt > ),然后在终端或者脚本中的 < span class = "cli" > query< / span > 命令之后粘贴所要查找的整个查询词。< / p >
2015-01-17 20:26:33 +03:00
< / td > < / tr >
< tr > < td > < p > < span class = "cli" > waitfor< / span > < / p > < / td > < td style = "width:10px;" > < / td >
< td valign = "top" > < p > < span class = "cli" > waitfor< / span > 是一个用于等待特殊的程序或者进程启动或者终止的非常好的方式。< / p >
2010-07-08 22:03:41 +04:00
< / td > < / tr > < / table >
< h3 > < a href = "#" > < img src = "../../images/up.png" style = "border:none;float:right" alt = "index" / > < / a >
2010-07-21 19:52:50 +04:00
< a id = "cli-other" name = "cli-other" > 其他命令< / a > < / h3 >
2010-07-08 22:03:41 +04:00
< table summary = "scripting cli tools" border = "0" cellpadding = "2" cellspacing = "0" >
< tr > < td > < p > < span class = "cli" > checkfs< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2015-01-17 20:26:33 +03:00
< td > < p > < span class = "cli" > checkfs< / span > 是一个非常重要的工具,主要用于检查文件系统中的错误。只需在该命令之后添加磁卷,如 < span class = "path" > /Haiku< / span > 或者设备名,它就会遍历所有的文件,然后修复所有可能出现不一致的地方。< / p >
2010-07-08 22:03:41 +04:00
< / td > < / tr >
< tr > < td > < p > < span class = "cli" > desklink< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2015-01-17 20:26:33 +03:00
< td valign = "top" > < p > < span class = "cli" > desklink< / span > 可以为任何文件,文件夹,查询或者程序在桌面栏托盘中安装图标。它也可以为相应的图标提供一个右键菜单。例如,尝试下面的脚本,为 < span class = "app" > Screenshot< / span > 添加不同的选项 (第一行中的"< tt > \< / tt > " 用于在终端中进行换行):
2010-12-04 22:04:43 +03:00
< / p >
< pre class = "terminal" > desklink "cmd=Active window (2s):/boot/system/apps/Screenshot --window --border --delay 2" \
"cmd=Remove replicant:desklink --remove=Screenshot" /boot/system/apps/Screenshot
2010-07-08 22:03:41 +04:00
< / pre >
< p > < img src = "../images/apps-images/cli-desklink.png" alt = "cli-alert.png" / > < / p >
2013-02-18 00:51:59 +04:00
< / td > < / tr >
< tr > < td > < p > < span class = "cli" > diskimage< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2015-01-17 20:26:33 +03:00
< td valign = "top" > < p > < span class = "cli" > diskimage< / span > 可用于注册普通文件作为磁盘设备。例如,您可以注册 Haiku anyboot 镜像,将其挂载在文件浏览器中,并且可以在安装器使用之前,编辑和移动其中的文件。< / p >
2013-02-18 00:51:59 +04:00
< / td > < / tr >
2016-05-06 05:15:13 +03:00
< tr > < td > < p > < span class = "cli" > mountvolume< / span > < br / > < span class = "cli" > mount< / span > < / p > < / td > < td style = "width:10px;" > < / td >
< td valign = "top" > < p > < span class = "cli" > mountvolume< / span > is preferred by many to mount local partitions and disks, because its usage is so easy: just call it with the name of the partition and you're done. Try < tt > --help< / tt > for more options.< / p >
< p > < span class = "cli" > mount< / span > can additionally mount remote disks by using a network filesystem, like NFS4. You specify the used filesystem with the < tt > -t< / tt > parameter and the remote location with the < tt > -p< / tt > parameter. As filesystem parameter you can use anything you find in < span class = "path" > /system/add-ons/kernel/file_system< / span > (and corresponding file hierarchies under < span class = "path" > ~/config< / span > or "< span class = "path" > non-packaged< / span > ", of course). You also have to create a folder as mountpoint. Here's an example:< / p >
< pre class = "terminal" > mkdir -p /DiskStation
mount -t nfs4 -p "192.168.178.3:volume1" /DiskStation< / pre > < / td > < / tr >
2013-02-18 00:51:59 +04:00
< tr > < td > < p > < span class = "cli" > open< / span > < / p > < / td > < td style = "width:10px;" > < / td >
2015-01-17 20:26:33 +03:00
< td valign = "top" > < p > < span class = "cli" > open< / span > 是一个非常小巧的工具。通过它,您可以以默认的程序打开任何文件,或者利用程序的签名还打开该程序而无需知道它的路径。它也可以用于打开网页,甚至“虚拟” 的目录, < tt > .< / tt > 用于当前目录或者 < tt > ..< / tt > 用于上层目录,并且可以在 Tracker 中打开相应的文件夹。< / p >
2013-02-18 00:51:59 +04:00
< / td > < / tr >
< / table >
2010-07-08 22:03:41 +04:00
< / div >
< / div >
< div class = "nav" >
< div class = "inner" > < span >
2010-12-30 22:10:45 +03:00
« < a href = "list-cli-apps.html" > 命令列表< / a >
2013-02-18 00:51:59 +04:00
:: < a href = "../applications.html#cli-apps" class = "uplink" > 应用程序
< / a >
2010-07-08 22:03:41 +04:00
< / span > < / div >
< / div >
< / body >
< / html >