<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    weidagang2046的專欄

    物格而后知致
    隨筆 - 8, 文章 - 409, 評(píng)論 - 101, 引用 - 0
    數(shù)據(jù)加載中……

    Osh

    In a Unix shell, you can run a series of commands, connecting the output of one command with the input to the next command using pipes. The information passed from one command to the next is normally organized into lines of text. Tools such as awk and sed are designed to extract and transform information from these lines. It would be much simpler if the data passed between commands was organized into objects. Osh is based on this idea. Osh is implemented in Python, so much of osh will be familiar if you already know Python.

    Osh is not a shell. It is an executable implementing a language that supports the composition of commands through piping. The objects piped from one command to the next can be Python primitives (numbers, lists, maps, etc.), other useful types such as dates/times, or database rows; or represent various OS resources such as files, directories, and processes. Conversions between objects and strings simplify integration with the Unix environment. The commands included with osh manipulate objects, access databases, and execute commands remotely, including parallel execution on nodes in a cluster. In a single osh invocation, all commands run in a single process. Multithreading is used only when executing commands on a cluster.

    Example: Suppose you have a cluster named fred, with nodes fred1, fred2, fred3. Each node has a database tracking work requests with a table named request. You can find the total number of open requests in each database as follows:

    [jao@zack] osh @fred [ sql "select count(*) from request where state = 'open'" ] ^ out
    ('fred1', 1)
    ('fred2', 0)
    ('fred3', 5)
    
    • osh: Invokes the osh executable.
    • @fred [ ... ]: Specifies that the following command, delimited by [...] should be run on each node of the cluster named fred. (The osh configuration file, .oshrc, specifies how to connect to the nodes of the cluster.)
    • sql "select count(*) from request where state = 'open'": Sql is an osh command that submits a query to a relational database. The query output is returned as a set of tuples.
    • ^ out: ^ is the osh operator for piping objects from one command to the next In this case, the input objects are tuples resulting from execution of a SQL query on each node of the cluster. The out command renders each object as a string and prints it to stdout.
    • Each output row identifies the node of origination (e.g. fred1, fred2), and contains a tuple from the database on that node. So ('fred3', 5) means that the database on node fred3 has 5 open requests.

    Example, continued: Now suppose you want to find the total number of open requests across the cluster. You can pipe the tuples into an aggregation command:

    [jao@zack] osh @fred [ sql "select count(*) from request where state = 'open'" ] ^ agg 0 'total, node, count: total + count' $
    6
    
    • agg: agg is the aggregation command. Tuples from across the cluster are piped into the agg command, which will accumulate results from all inputs.
    • 0: This use of agg will maintain a total, which is initialized to 0.
    • 'total, node, count: total + count': This specifies an aggregation function. total is the running total, which was initialized to 0. node and count come from the sql command executed on each node of the cluster. total + count accumulates the counts from each node.
    • $: An alternative to ^ out that can be used at the end of a command only.
    • 6: The total of the counts from across the cluster.

    More information:

    License: GPL
    Release history
    Tutorial (TBD)
    User guide
    Download
    Software with similar goals


    jao@geophile.com

    from: http://geophile.com/osh/

    posted on 2005-11-24 19:06 weidagang2046 閱讀(558) 評(píng)論(0)  編輯  收藏 所屬分類: Python


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国内外成人免费视频| 午夜影院免费观看| 在线观看免费大黄网站| 亚洲日韩中文字幕天堂不卡| 免费观看在线禁片| 久久精品国产精品亚洲色婷婷| 91精品成人免费国产| 久久夜色精品国产亚洲AV动态图| 怡红院免费全部视频在线视频| 国产精品亚洲аv无码播放| a级成人毛片免费图片| 亚洲精品高清国产一久久| 在线a免费观看最新网站| 亚洲精品一区二区三区四区乱码| 6080午夜一级毛片免费看6080夜福利| 久久久久亚洲Av无码专| 噼里啪啦免费观看高清动漫4| 亚洲天堂2017无码中文| 国产精品久免费的黄网站| 特级毛片全部免费播放a一级| 亚洲午夜av影院| 99精品免费观看| 亚洲av无码久久忘忧草| 国产午夜免费福利红片| 国产黄色片免费看| 久久精品国产亚洲77777| 一二三四视频在线观看中文版免费 | 精品国产亚洲一区二区三区 | 免费一区二区无码视频在线播放| 亚洲性在线看高清h片| 久久免费观看国产精品88av| 亚洲13又紧又嫩又水多| 免费v片视频在线观看视频| 爱丫爱丫影院在线观看免费| 亚洲免费中文字幕| 国产又黄又爽又刺激的免费网址| a级午夜毛片免费一区二区| 亚洲人成在线中文字幕| 亚洲国产精品国产自在在线| 曰批全过程免费视频播放网站| 婷婷国产偷v国产偷v亚洲|